pdf文件无法预览?
检查一下new Blob第一个参数是不是文件流,是一个数组,如下:
new Blob([response], { type: "application/pdf;charset-UTF-8" })
pdf预览出现空白页?
检查:
1、responseType: “blob”
2、type: “application/pdf;charset-UTF-8”
正确代码如下:
$http.get(newVal, {
responseType: "blob",
})
.then((response) => {
_this.pdfSrc = window.URL.createObjectURL(
new Blob([response], { type: "application/pdf;charset-UTF-8" })
);
_this.pdfSrc = haloseeUiUtil.replaceBaseUrl(_this.pdfSrc);
console.log("121==", _this.pdfSrc);
})
.catch((err) => {});