preview.vue 791 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <template>
  2. <web-view :src="webSrc"/>
  3. </template>
  4. <script setup>
  5. import {ref, onMounted, getCurrentInstance} from "vue";
  6. import {onLoad} from '@dcloudio/uni-app'
  7. //初始变量
  8. let wv;
  9. const instance = getCurrentInstance().proxy
  10. const webSrc = ref('');
  11. onLoad((option) => {
  12. if (option.url) {
  13. webSrc.value = '/hybrid/html/pdf/web/viewer.html?file= ' + decodeURIComponent(option.url);
  14. }
  15. })
  16. //渲染完成
  17. onMounted(() => {
  18. // #ifdef APP-PLUS
  19. let currentWebview = instance.$scope.$getAppWebview()
  20. //如果是页面初始化调用时,需要延时一下
  21. setTimeout(function() {
  22. wv = currentWebview.children()[0]
  23. wv.setStyle({scalable:true})
  24. }, 1000);
  25. // #endif
  26. })
  27. </script>
  28. <style lang="scss">
  29. page {
  30. height: auto;
  31. }
  32. </style>