这是后端返的文件流
PK
前端对文件流处理代码:
const prints = (id:any) => {
print({id:id}).then((res:any) => {
// console.log("res==打印",res)
let blob = new Blob([res], {
type: `application/msword` //word文档为msword,pdf文档为pdf,excel为octet-stream
});
let objectUrl = URL.createObjectURL(blob);
let link = document.createElement("a");
let fname = `高处作业许可证文件打印`;//下载文件的名字
link.href = objectUrl;
link.setAttribute("download", fname);
document.body.appendChild(link);
link.click();
//释放内存
window.URL.revokeObjectURL(link.href);
})
}