【Vue】vue2使用vue-pdf插件

导入:

npm install --save vue-pdf
<pdf
          v-for="i in numPages"
          :key="i"
          :src="src"
          :page="i"
          style="display: inline-block; width: 50%"
        ></pdf>
date中:
data() {
    return {
      numPages: undefined,
      peopleIndex: null,
      src: null,
      }
    }
methods方法
 showPDF(people, i) {
      console.log(i)
      this.peopleIndex = i
      this.loadPDF(people.pdf)
      this.showPdf = true
    },
    loadPDF(src) {
      this.src = pdf.createLoadingTask(src)
      this.src.promise.then((pdf) => {
        console.log(pdf)
        this.numPages = pdf.numPages
      })
    },
posted @ 2022-08-07 21:07  一个大不刘blog  阅读(262)  评论(0编辑  收藏  举报