vue之使用 vue-pdf插件

vue之使用 vue-pdf插件

使用

html
    currentPage- {
    
    {
    
     currentPage}}
    <button @click="change1">上一页</button>
    <button @click="change2">下一页</button>
    <pdf :src="file.url" :page="currentPage" @num-pages="pageCount=$event" @page-loaded="currentPage=$event">
    </pdf>

js
import pdf from "vue-pdf";
export default {
    
    
  name: 'CheckDocument',
  components: {
    
    
    pdf,
  },
  data() {
    
    
    return {
    
    
      file: {
    
    
        url: `${
      
      window.location.origin}/test1.pdf`
      },
      currentPage: 1,
      pageCount: 1,
    };
  },

    // 改变PDF页码,val传过来区分上一页下一页的值,0上一页,1下一页
    change1() {
    
    
      if (this.currentPage > 1) {
    
    
        this.currentPage--
      }
    },
    change2() {
    
    
      if (this.currentPage < this.pageCount) {
    
    
        this.currentPage++
      }
    }

猜你喜欢

转载自blog.csdn.net/weixin_47409897/article/details/124275041