<el-upload
action=""
:on-change="analyzeZip" >
<el-button
slot="trigger"
>上传测试数据</i
></el-button>
</el-upload>
<script>
// 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);
});
<script/>
虽然最后发现formdata.append(“file”,blob)还是会把blob转化成file,呵呵