正常文件导出直接用window.open 打开新窗口
window.open(window._server + '/report/down/' + item.id, '_blank');
因为要获取token 用ajax
/**
* 导出
* */
exportTemplate(item) {
$.ajax({
url: window._server + '/invocation/details-export/' + item.id,
type: 'GET',
xhrFields: {
responseType: "arraybuffer",
}, //解码
success: function (res, _, xhr) {
const fileName = '明细导出数据.xlsx';
let blob = new Blob([res], { type: "application/vnd.ms-excel", });
let link = document.createElement("a");
link.href = window.URL.createObjectURL(blob);
link.download = fileName;
link.click();
window.URL.revokeObjectURL(link.href);
},
error: function (req) {
}
});
}