直接上代码,一定要在响应头中加:responseType: “blob”,getResponse: true,
const data = id;
axios.post("/api/gsquality/app/printReport", {
data,
responseType: "blob",
getResponse: true,
})
.then((res) => {
let pdfUrl = window.URL.createObjectURL(
new Blob([res.data], { type: "application/pdf" })
);
window.open(pdfUrl);
})
.catch((err) => {});