static下pdfjs
上代码
<template> <div class="pdfjs"> <iframe width="100%" frameborder="0" style="width: 100%; height: 100%;" v-if ="src" :src="pdfSrc"></iframe> </div> </template> <script> export default { components: { }, data() { return { // 参数展示pdf地址 src: "https://aaeasy-file.newbanker.cn/pic/testforyuhan/裴士杰的专属报告_2021-11-02_11_17_21.pdf", // pdfjs模板 viewerUrl: '/static/pdfjs/web/viewer.html', pdfSrc: '', }; }, methods: { loadPDF() { this.pdfSrc=`${this.viewerUrl}?file=${encodeURIComponent(this.src)}` }, }, mounted: function() { this.loadPDF(); }, }; </script> <style lang="scss" scoped> .pdfjs {width:100%; height: 90vh;} </style>