//生成PDF
this.$http.post(this.url + "api/Tmessage", { ”传给后端的数据“ },{ responseType: 'blob' }).then(data => {
var uInt8Array = new Uint8Array(data.data);
let blob = new Blob([uInt8Array], { type: "application/pdf" });
let blobURL = window.URL.createObjectURL(blob);
let tempLink = document.createElement('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);
})
.net6生成PDF,前端使用vue接收并自动下载(亲测有效)
最新推荐文章于 2024-07-24 11:09:48 发布