【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
})
},