export function convertBase64ToBlob(base64) {
var base64Arr = base64.split(',');
var imgtype = '';
var base64String = '';
if (base64Arr.length > 1) {
base64String = base64Arr[1];
imgtype = base64Arr[0].substring(base64Arr[0].indexOf(':') + 1, base64Arr[0].indexOf(';'));
}
var bytes = atob(base64String);
var bytesCode = new ArrayBuffer(bytes.length);
var byteArray = new Uint8Array(bytesCode);
for (var i = 0; i < bytes.length; i++) {
byteArray[i] = bytes.charCodeAt(i);
}
return new Blob([bytesCode], { type: imgtype });
}
我建了一个前端微信交流群,欢迎大家加入,qq中转群号:1076484243
网友评论