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,
};
},
change1() {
if (this.currentPage > 1) {
this.currentPage--
}
},
change2() {
if (this.currentPage < this.pageCount) {
this.currentPage++
}
}