axios({
method: "get",
url: this.$api + "comm-file/downloadCommonFile",
params: {
fileId: this.fileId,
},
responseType: 'blob',
}).then(res => {
loading.close();
console.log('res', res);
if (res.status == "500") {
this.$message({
message: '下载失败!',
type: 'error'
});
return;
}
//文件以pdf形式进行预览
let blob = new Blob([res.data], {
type: 'application/pdf;chartset=UTF-8'
})
let fileURL= URL.createObjectURL(blob)
window.open(fileURL)
记axios实现blob文件在线预览二进制流pdf
最新推荐文章于 2024-06-18 09:01:03 发布