tanghaolin
2022-08-30 88778310683dcb8befc0d0c6175f44a701e8b8d3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<template>
  <div :class="ishavetop?'pdfPageOne':'pdfPageTwo'">
    <!-- pdf容器 -->
    <div id="Demo"></div>
  </div>
</template>
 
<script>
import Pdfh5 from "pdfh5";
import "pdfh5/css/pdfh5.css";
export default {
  // 名字
  name: "PdfPage",
  // 部件
  components: {
  },
  // 静态
  props: {
      ishavetop:Boolean,
 
    pdfSrc: {
      type: String,
      default: ""
    }
  },
  // 数据
  data() {
    return {
      isLoading:false,
      pdfh5: null,
      currentPage:0,//当前页数
      pageCount:0,//总页数
    };
  },
  // 属性的结果会被缓存,除非依赖的响应式属性变化才会重新计算。主要当作属性来使用;
  computed: {},
  // 对象内部的属性监听,也叫深度监听
  watch: {},
  // 请求数据
  created() {},
  mounted() {
    if(this.pdfSrc == "" || this.pdfSrc == null){
      return
    }
    console.log(this.pdfSrc,45)
        //实例化
      this.pdfh5 = new Pdfh5("#Demo", {
      pdfurl: this.pdfSrc,
      lazy:true 
      });
 
  },
  // 方法表示一个具体的操作,主要书写业务逻辑;
  methods: {
  }
};
</script>
 
<style>
/* 加载框 */
.mask {
  width: 100vw;
  height: 100%;
  position: relative;
}
  .mask .van-loading {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
  }
.pdfPageOne {
  height: calc(100% - 238px);
  overflow:auto;
}
.pdfPageTwo {
  height: calc(100% - 0px);
  overflow:auto;
}
 
</style>