后端返回二进制excel,如何下载
axios({
url:
config.Urls.serverUrl + "/load/airdoc/result/export/getAppraisalData",
method: "POST",
responseType: "blob",
data: param,
}).then((res) => {
// console.log(res.data);
let date = new Date();
let y = date.getFullYear();
let m = date.getMonth() + 1;
let d = date.getDate();
let result = res.data; //如果后端返回的result是进过Blob处理的,直接 window.URL.createObjectURL(result),如果没有,就需要先实例化new Blod处理之后再window.URL.createObjectURL(blob)。
let blob = new Blob([result], { type: "application/vnd.ms-excel" });
let url = window.URL.createObjectURL(blob);
let link = document.createElement("a");
link.download = y + "-" + m + "-" + d + "身心健康屏企业报告";
link.href = url;
link.click();
});