vue axios PDF文件流下载
this.axios({method: "post",url: '/jishi/jishi.daochu',responseType: 'blob',data: data //需要传的字段}).then((res) => {let blob = new Blob...
·
this.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();
})
更多推荐
已为社区贡献3条内容
所有评论(0)