前端处理后端返回的文件流做导出操作


import { post } from 'axios';
// 导出
exportNoticeData() {
post(
'/safetyjapi/pic/gateWay/noticeExport',
{ ...this.entNameParams },
{
responseType: 'blob',
}
)
.then(res => {
if (res.status === 200) {
const blob = new Blob([res.data], {
type: 'application/ms-excel',
});
const reader = new FileReader();
reader.readAsDataURL(blob);
reader.onload = e => {
const a = document.createElement('a');
a.download = '公告栏.xls';
a.href = e.target.result;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
};
}
})
.catch(err => {
console.log(err.message);
});
},


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM