1、下载pdf-viewer源文件 放到项目public中
注意,上面的文件精简过,需要完整的请去官网下载https://mozilla.github.io/pdf.js/getting_started/#download


2、修改源文件中的资源路径
注意"/h5"可以去掉,h5是我这边的服务器资源目录

3、使用pdf-viewer预览pdf文件
c
<iframe class="iframe" :src="viewerUrl" frameborder="0" allowfullscreen></iframe>
const viewerUrl = ref('/h5/pdf-viewer/viewer.html?file=https://xxx-oss-xxx.oss-cn/file/2026/6/1/20613.pdf')