1、经常会用到导入导出,做个笔记给自己
this.axios
.post("/service",params,{
responseType: "arraybuffer"
})
.then((res) => {
let a = document.createElement("a");
let blob = new Blob([res.data]);
let objectUrl = URL.createObjectURL(blob);
a.setAttribute("href", objectUrl);
a.setAttribute("download", "测试.xls");
a.click();
URL.revokeObjectURL(objectUrl); // 释放内存
})