previewPdf2.vue 767 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <template>
  2. <view class="pdf-container">
  3. <view id="demo"></view>
  4. </view>
  5. </template>
  6. <script>
  7. import Pdfh5 from "pdfh5";
  8. export default {
  9. name: 'App',
  10. data() {
  11. return {
  12. pdfh5: null,
  13. pdfUrl: ''
  14. };
  15. },
  16. onLoad(page) {
  17. if (page.fileUrl) {
  18. this.pdfUrl = page.fileUrl
  19. }
  20. },
  21. mounted() {
  22. //实例化
  23. this.pdfh5 = new Pdfh5("#demo", {
  24. pdfurl: this.pdfUrl
  25. });
  26. //监听完成事件
  27. this.pdfh5.on("complete", function(status, msg, time) {
  28. console.log("状态:" + status + ",信息:" + msg + ",耗时:" + time + "毫秒,总页数:" + this.totalNum)
  29. })
  30. }
  31. }
  32. </script>
  33. <style lang="scss" scoped>
  34. @import "./pdfh5.css";
  35. .pdf-container {
  36. width: 100%;
  37. min-height: calc(100vh - 88rpx);
  38. }
  39. </style>