1、首先先將 pdfjs-2.8.335-dist 文件夾從網(wǎng)上搜索下載,復(fù)制到public文件夾下.
2、在components下新建組件PdfViewer.vue文件
3、在el-upload 中調(diào)用 pdf-viewer 組件
4、在el-upload 中的 on-preview方法中加上對(duì)應(yīng)的src路徑
?internalPreview(file) {
//判斷需要預(yù)覽的地方加 props—pdfView
? ? ? ? ? ? ? ? if(this.pdfView){
? ? ? ? ? ? ? ? ? ? let baseApi = process.env.VUE_APP_BASE_API;
? ? ? ? ? ? ? ? ? ? let _path = file?.path;
? ? ? ? ? ? ? ? ? ? this.src = `${baseApi}${_path}`
? ? ? ? ? ? ? ? }文章來源:http://www.zghlxwxcb.cn/news/detail-806084.html
}文章來源地址http://www.zghlxwxcb.cn/news/detail-806084.html
到了這里,關(guān)于vue2 pdfjs-2.8.335-dist pdf文件在線預(yù)覽功能的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!