// 需要安装 vue-pdf插件
import pdf from 'vue-pdf';
// pdf 预览
getPdfUrl() {
if(this.formData.businessTicketFrontPath) {
getImgUrl(this.formData.businessTicketFrontPath).then(res=>{
console.log('res:',res);
this.pdfVisible = true;
const {data, header} = res
const blob = new Blob([data])
let url = window.URL.createObjectURL(blob)
this.getNumPages(url)
})
}
},
getNumPages(pdfUrl) {
var loadingTask = pdf.createLoadingTask(pdfUrl)
loadingTask.promise.then(pdf => {
this.pdfUrl = loadingTask
this.numPages = pdf.numPages
}).catch((err) => {
console.error('pdf加载失败')
})
},
网友评论