axios.post(url, params,{
responseType: 'arraybuffer' //加上responseType: 'arraybuffer',不然下载的PDF是空白页
}).then(res => {
()
}).catch(err => {
console.log(err);
})
this.$downpdf(params,response=>{
const pdfUrl = window.URL.createObjectURL(new Blob([response], { type: `application/pdf` }));
const link = document.createElement('a');
link.href = pdfUrl;
link.setAttribute('download', name);
document.body.appendChild(link);
link.click();
})
js下载后台返回的流文件
最新推荐文章于 2023-12-26 17:34:16 发布