<pdf
                  v-for="i in numPages"
                  :key="i"
                  :page="i"
                  :src="pdfUrl" style="width: 100%; height: auto;" @num-pages="pageCount=$event">
                </pdf>

data() {
      return {
        pageCount:0,
        pdfUrl:'',
        src: '', // pdf文件地址
        numPages:0,
      }
    },
mounted(){
this.loadPdfHandler()
},
methods: {
      async loadPdfHandler () {
        //src为你服务器上存放pdf的路径
        this.pdfUrl = pdf.createLoadingTask(this.src);
        this.pdfUrl.then(pdf => {
          this.numPages = pdf.numPages
        })
      },
},

 

Logo

前往低代码交流专区

更多推荐