目前项目中,移动端和 PC端都有pdf预览的需求,个人建议PC端用vue-pdf,能很好地实现分页的效果,移动端建议用pdfh5.js,一次性加载,滑动查看,先记录下vue-pdf
1.安装:npm install --save vue-pdf
2.引入:
import pdf from 'vue-pdf'
components: {pdf}
3.写template
<div class="pdf" v-show="fileType === 'pdf'">
<p class="arrow">
// 上一页
<span @click="changePdfPage(0)" class="turn" :class="{grey: currentPage==1}">Preview</span>
{
{currentPage}} / {
{pageCount}}
// 下一页
<span @click="changePdfPage(1)" class="turn" :class="{grey: currentPage==pageCount}">Next</span>
</p>
// 引入就可以使用,这里我的需求是做了分页功能,如果不需要分页功能,只要src就可以了
<pdf
:src=&#