将文件转化为PDF预览
//userAgreementId:文件id
//getFileUrlApi:通过文件id获取文件url的接口
import { Base64 } from 'js-base64'
const previewFile = (userAgreementId: string) => {
getFileUrlApi(userAgreementId).then((res) => {
console.log(res)
const { data } = res
const url = 'http://192.168.131.166:9000' + data
window.open(
'http://192.168.131.168:8012/onlinePreview?url=' + encodeURIComponent(Base64.encode(url))
)
})
}
如果想嵌入到页面中显示(预览):
//urlSrc: 'http://192.168.131.168:8012/onlinePreview?url=' + encodeURIComponent(Base64.encode(url))
<iframe :src="urlSrc" width="100%" height="600" style="border: none"> </iframe>