解法:
//axios
return request({
url: "/saleUnit/exportSaleUnit",
headers: {
"biz-source-param": "BLG"
},
method: "post",
responseType: "blob",
data: params
});
let blob = new Blob([res], { type: "application/x-xls" }); let link = document.createElement("a"); link.href = window.URL.createObjectURL(blob); link.download = `便利購商品列表${this.$dayjs().format( "YYYYMMDDHHmmss" )}.xlsx`; link.click(); this.$message.success("下載成功!");
服務端返回的數據截圖
響應頭
前端下載腳本
下載的excel
wps打開失敗