// file转blob
fileToBlob(file, callback) {
const type = file.type;
const reader = new FileReader();
reader.onload = (evt) => {
const blob = new Blob([evt.target.result], { type });
if (typeof callback === "function") {
callback(blob);
} else {
console.log("我是 blob:", blob);
}
};
reader.readAsDataURL(file);
},
analyzeZip(file) {
const _file = file.raw;
this.fileToBlob(_file, async (blob) => {
console.log(blob);
});
标签:el,const,upload,js,callback,blob,file,reader,type From: https://www.cnblogs.com/freddyhuang/p/17706470.html