El fondo es java, este artículo solo muestra el código del front-end
1. Primero configure el responseType en formato blob.
const getMerchantAuditListByWhereExcel = p => request.get('/xxx/xxxx', {
params: p,
responseType: 'blob'
}) // 订单管理-导出全部查询结果订单信息Excel
2. El código de función ejecutado
// 搜索导出全部内容
seachExport() {
let param = {
// 需要传递的参数
};
getMerchantAuditListByWhereExcel(param).then(res => {
this.download(res);
});
},
// 下载文件
download(data) {
if (!data) {
return;
}
let url = window.URL.createObjectURL(new Blob([data.data]));
let a = document.createElement("a");
a.style.display = "none";
a.href = url;
a.setAttribute("download", "自营订单列表.xls");
document.body.appendChild(a);
a.click();
},