vue 预览PDF(文件流格式)

安装:

npm install vue-pdf-signature

引入:

import pdf from 'vue-pdf-signature';

import CMapReaderFactory from 'vue-pdf-signature/src/CMapReaderFactory';
components: { pdf,CMapReaderFactory},

预览标签:

<!-- pdf -->
<pdf ref="pdf" :src="pdfSrc" class="pdf" style=""></pdf> 

 绑定方法:

getPdf(row.id).then(response => {
        // console.log(response);
        const blob = new Blob([response], { type: 'application/pdf' })
        this.pdfSrc =window.URL.createObjectURL(blob)
        console.log(this.pdfSrc);
        window.open(this.pdfSrc)//新窗口打开,借用浏览器去打印
        // this.$refs.pdf.print();//这个打印调不起来,一直显示print方法找不到
});

 就这样吧

posted @ 2022-04-01 11:27  微凉_1993  阅读(2931)  评论(0编辑  收藏  举报