js如何实现base64转文件下载保存到本地
//将base64转换为blob
dataURLtoBlob(dataurl) {
var arr = dataurl.split(","),
mime = arr[0].match(/:(.*?);/)[1],
bstr = atob(arr[1]),
n = bstr.length,
u8arr = new Uint8Array(n);
while (n--) {
u8arr[n] = bstr.charCodeAt(n);
}
return new Blob([u8arr], { type: mime });
},
//下载方法
downloadFile(url, name = "What's the fuvk") {
var a = docum
共有 0 条评论