axios({
method: 'post',
url: 'URL',
responseType: 'blob',
})
.then(async res => {
let blob = new Blob([res.data], { type: 'application/vnd.ms-excel;charset=utf-8' });
let href = window.URL.createObjectURL(blob); //创建下载的链接
const link = document.createElement('a');
link.href = href;
link.download = '报表汇总.xlsx';
link.click();
})
.catch(error => {
console.error(error);
// 处理错误
});
后端返回二进制,前端导出excel
于 2024-04-07 15:04:27 首次发布