This is a JavaScript function that converts a base64 encoded string to a Blob object with the specified MIME type.

The function takes in two parameters:

  1. base64: a base64 encoded string. The split(',')[1] method is used to remove the data URL header before decoding the base64 string.
  2. type: the MIME type of the resulting Blob object.

The function first uses the atob() method to decode the base64 string into a binary string. It then creates a new Uint8Array with the length of the binary string and fills it with the character codes from the binary string using a while loop. Finally, it returns a new Blob object with the Uint8Array as its data and the specified MIME type

uniapp base64ToBlobbase64 type 			 const bstr = atobbase64split1			 let n = bstrlength			 const u8arr = new Uint8Arrayn			 while n-- 			 u8arrn = bstrcharCodeAtn

原文地址: https://www.cveoy.top/t/topic/hdUR 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录