安装插件
npm install pdfh5
使用
<template><el-container class="resPreview"><div ref="refPdf"/></el-container>
</template><script setup name="PreviewBox">import { ref } from 'vue' import { httpGetBlob } from '../utils/request' import Pdfh5 from 'pdfh5'import 'pdfh5/css/pdfh5.css'/* 预览PDF */const refPdf = ref(null)const LoadPdf = url => {const pdfh5 = new Pdfh5(refPdf.value, {pdfurl: url})pdfh5.on('complete', (status, msg, time) => {console.log('状态:' + status + ',信息:' + msg + ',耗时:' + time + '毫秒')})}httpGetBlob(downloadPdf).then(blobData=> {if (blobData) {LoadPdf(window.URL.createObjectURL(new Blob([blobData])))} })
https://github.com/JackieZheng/pdfh5https://github.com/JackieZheng/pdfh5