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,
    })
} 

猜你喜欢

转载自www.cnblogs.com/chengyunshen/p/10966796.html