前端處理后端返回的文件流做導出操作


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