base64TurnImg.js 360 B

123456789101112
  1. //base64转Blob
  2. export function base64ToBlob(base64, type) {
  3. console.log(base64);
  4. const bstr = atob(base64.replace(/^[^,]+,/, ''))
  5. let n = bstr.length
  6. const u8arr = new Uint8Array(n)
  7. while (n--) {
  8. u8arr[n] = bstr.charCodeAt(n)
  9. }
  10. // return new Blob([u8arr], { type: type || '' })
  11. return new Blob([u8arr], { type: type || 'image/jpeg' })
  12. }