uniapp base64ToBlobbase64 type const bstr = atobbase64split1 let n = bstrlength const u8arr = new Uint8Arrayn while n-- u8arrn = bstrcharCodeAtn
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:
base64: a base64 encoded string. Thesplit(',')[1]method is used to remove the data URL header before decoding the base64 string.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
原文地址: https://www.cveoy.top/t/topic/hdUR 著作权归作者所有。请勿转载和采集!