前端用 js-file-download组件下载后端返回的pdf,word,excel文件

后端返回的pdf,word,excel的文件流导出需要让浏览器下载文件

1、安装js-file-download组件

npm install js-file-download --save

2、在对应的页面引用

import fileDownload from "js-file-download";

3、在接口返回结果后直接调用即可

let data={
    id:processId,
    customerId:customerId
}
//后台导出文件接口
feeNotification(data).then(res => {
    //调用fileDownload即可
    fileDownload(res, 'xxxx.xlsx');
})