// 图片路径返回base64
chooseStaticImg(imageUrl) {
let th = this;
this.getImageFileFromUrl(imageUrl, "图片.gif", function(file) {
let reader = new FileReader();
reader.onloadend = function() {
th.base64 = reader.result;
};
reader.readAsDataURL(file);
});
},
// 根据路径返回file
getImageFileFromUrl(url, imageName, callback) {
fetch(url)
.then((res) => {
return res.blob();
})
.then((blob) => {
let imgFile = new File([blob], imageName, { type: "image/gif" });
callback(imgFile);
});
},