官方下载:
同目录下pdfjs-2.12.313-dist.zip为官方下载包
此包为pdf白色背景
 
使用中遇到问题:找不到viewer.html
解决方法:把里面的viewer copy出来扔到public或者static里面

 

 

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>