js中 base64 转二进制

function base64toBlob(base64,type) {  
    // 将base64转为Unicode规则编码
   let  bstr = atob(base64, type),  
     n = bstr.length,  
    u8arr = new Uint8Array(n);  
    while (n--) {  
        u8arr[n] = bstr.charCodeAt(n) // 转换编码后才可以使用charCodeAt 找到Unicode编码
    }  
    return new Blob([u8arr], {  
        type,
    })
} 

posted @ 2019-06-03 12:22  橙云生  阅读(5523)  评论(0编辑  收藏  举报