base64转blob


export function convertBase64ToBlob (imgData,imgType) {
    let bytes=window.atob(imgData);        //去掉url的头,并转换为byte  
    let imgBuffer = new ArrayBuffer(bytes.length);   //处理异常,将ascii码小于0的转换为大于0  
    let imgUnit = new Uint8Array(imgBuffer);
    for (var i = 0; i < bytes.length; i++) {  
        imgUnit[i] = bytes.charCodeAt(i);  
    }  
    return new Blob( [imgBuffer] , {type: imgType});    // 'image/png'
}

posted @ 2019-04-16 17:26  LeesonVictor  阅读(769)  评论(0编辑  收藏  举报