-函数
async function blobToBase64(blob) { let buffer = await blob.arrayBuffer() let bytes = new Uint8Array(buffer); // do anything with the byte array here let binary = '' var len = bytes.byteLength; for (var i = 0; i < len; i++) { binary += String.fromCharCode(bytes[i]); } base64 = 'data:image/webp;base64,' + window.btoa(binary) // return base64 }
-使用
blobToBase64(blobInfo.blob()).then(base64 => { console.log(base64); }); });