pdfPage.vue 559 B

123456789101112131415161718192021222324252627282930
  1. <template>
  2. <view>
  3. <web-view v-if="pdfUrl" :src="pdfUrl"></web-view>
  4. </view>
  5. </template>
  6. <script setup>
  7. import {ref} from "vue"
  8. import {onLoad} from "@dcloudio/uni-app"
  9. const pdfUrl = ref('');
  10. const httpUrl = ref('');
  11. function updatePdfUrl(url) {
  12. httpUrl.value = url;
  13. pdfUrl.value = '/hybrid/html/web/viewer.html?file=' + encodeURIComponent(url);
  14. }
  15. onLoad(({url}) => {
  16. const mockUrl = "https://501351981.github.io/vue-office/examples/dist/static/test-files/test.pdf"
  17. updatePdfUrl(url||mockUrl);
  18. })
  19. </script>
  20. <style>
  21. </style>