axios({
method: "post",//请求方式
url: '/jishi/jishi.daochu',
responseType: 'blob',
data: data //需要传的字段
}).then((res) => {
let blob = new Blob([res.data], {
type: `application/pdf` //word文档为msword,pdf文档为pdf
});
let objectUrl = URL.createObjectURL(blob);
let link = document.createElement("a");
let fname = `信息表pdf`; //下载文件的名字
link.href = objectUrl;
link.setAttribute("download", fname);
document.body.appendChild(link);
link.click();
})
vue项目,通过axios请求下载pdf文件
最新推荐文章于 2023-11-29 16:27:24 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)