// base64转url
// const file = this.base64ImgtoFile(contractData); // 得到File对象
// const imgUrl =
// window.webkitURL.createObjectURL(file) ||
// window.URL.createObjectURL(file); // imgUrl图片网络路径
// base64转url
base64ImgtoFile(dataurl: any, filename = "file") {
const arr = dataurl.split(",");
const mime = arr[0].match(/:(.*?);/)[1];
const suffix = mime.split("/")[1];
const bstr = atob(arr[1]);
let n = bstr.length;
const u8arr = new Uint8Array(n);
while (n--) {
u8arr[n] = bstr.charCodeAt(n);
}
return new File([u8arr], `${filename}.${suffix}`, {
type: mime,
});
}
atob() 不可用使用 atob(btoa(data))