vue-pdf放大缩小,上一页下一页,滚动翻页

以下是上一页下一页,放大缩小:

 
翻页缩小:
  
  • 上一页

  • 下一页

import pdf from "vue-pdf"; export default { name: "inspectionPresentation", components: { pdf }, data() { return { currentPage: 0, // pdf文件页码 pageCount: 0, // pdf文件总页数 path: this.$route.params.path, scale: 100, //放大系数 idx: -1, clauseTitle: "", loadedRatio: 0 }; }, methods{ // 改变PDF页码,val传过来区分上一页下一页的值,0上一页,1下一页 changePdfPage(val) { if(val === 0 && this.currentPage > 1) { this.currentPage--; } if(val === 1 && this.currentPage < this.pageCount) { this.currentPage++; } }, goBack() { this.$router.go(-1); }, // pdf加载时 loadPdfHandler(e) { this.currentPage = 1; // 加载的时候先加载第一页 }, //放大 scaleD() { this.scale += 5; // this.$refs.wrapper.$el.style.transform = "scale(" + this.scale + ")"; this.$refs.wrapper.$el.style.width = parseInt(this.scale) + "%"; }, //缩小 scaleX() { if(this.scale == 100) { return; } this.scale += -5; this.$refs.wrapper.$el.style.width = parseInt(this.scale) + "%"; // this.$refs.wrapper.$el.style.transform = "scale(" + this.scale + ")"; }, }

以下是滚动翻页,简单明了:

 

import pdf from "vue-pdf";
export default {
  name: "inspectionPresentation",
  components: {
    pdf
  },
  data() {
    return {
      numPages: "",
src: this.$route.params.path,// pdf文件地址
     
    };
     methods: {
       // pdf加载时
		loadPdfHandler() {
		this.src.then(pdf => {this.numPages = pdf.numPages;});
     }
     created() {
		this.src = pdf.createLoadingTask(this.src);this.loadPdfHandler();
	},

你可能感兴趣的:(VUE,vue问题解决,vue.js)