el-upload file转blob 用于预览pdf.js和下载文件
// 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);
});
作者:freddyhuang
出处:https://www.cnblogs.com/freddyhuang
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。