后端返回的pdf,word,excel的文件流導(dǎo)出需要讓瀏覽器下載文件
1、安裝js-file-download組件
npm install js-file-download --save
2、在對(duì)應(yīng)的頁(yè)面引用文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-721082.html
import fileDownload from "js-file-download";
3、在接口返回結(jié)果后直接調(diào)用即可文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-721082.html
let data={
id:processId,
customerId:customerId
}
//后臺(tái)導(dǎo)出文件接口
feeNotification(data).then(res => {
//調(diào)用fileDownload即可
fileDownload(res, 'xxxx.xlsx');
})
到了這里,關(guān)于前端用 js-file-download組件下載后端返回的pdf,word,excel文件的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!