//生成PDF
this.$http.post(this.url + "api/Tmessage", { idf: frr, ido: oarr, idt: tarr, idh: harr, icr: scrr, ivr: svrr, ifr: sfrr, izr: szrr },{ responseType: 'blob' }).then(data => {
console.log(data.data[0])
var uInt8Array = new Uint8Array(data.data[0]); //先将返回的二进制数组转化为js的二进制数组
let blob = new Blob([uInt8Array], { type: "application/pdf" });//然后创建blob对象,文件类型设置为excel的类型
let blobURL = window.URL.createObjectURL(blob);//然后创建一个可访问的URL
let tempLink = document.createElement('a');//创建a标签去下载
tempLink.style.display = 'none';
tempLink.href = blobURL;
tempLink.setAttribute('download', "11.pdf");
if (typeof tempLink.download === 'undefined') {
tempLink.setAttribute('target', '_blank');
}
document.body.appendChild(tempLink);
tempLink.click();
document.body.removeChild(tempLink);
window.URL.revokeObjectURL(blobURL);
})
前端vue接收后端.net传来的PDF进行下载
最新推荐文章于 2024-09-02 17:34:07 发布