问题描述
pdf 文件使用iframe预览时会触发下载,所以先下载再使用blob临时链接展示。
// 使用文件链接下载
const res = await fetch(file.link)
.then((response) => response.blob())
const blob = new Blob([res], { type: 'application/pdf' })
// 使用文件id下载
const pdfRes = await oneFileDownload({ id: file.attachId || file.id })
const blob = new Blob([pdfRes.data], { type: 'application/pdf' })
const blobURL = URL.createObjectURL(blob) // 将blob对象转为一个URL
URL.revokeObjectURL(blobURL) // 释放临时url
