MtaPDF.vue 712 B

1234567891011121314151617181920212223242526272829303132
  1. <template>
  2. <view class="pdf-container">
  3. <template v-if="systemInfo.platform == 'android'">
  4. <web-view v-if="pdfUrl"
  5. :src="`https://mozilla.github.io/pdf.js/web/viewer.html?file=${encodeURIComponent(pdfUrl)}`"
  6. class="web-view"></web-view>
  7. </template>
  8. <template v-else>
  9. <web-view v-if="pdfUrl" :src="pdfUrl" class="web-view"></web-view>
  10. </template>
  11. </view>
  12. </template>
  13. <script setup>
  14. const props = defineProps({
  15. pdfUrl: {
  16. type: String
  17. }
  18. })
  19. const systemInfo = uni.getSystemInfoSync();
  20. </script>
  21. <style lang="scss">
  22. .pdf-container {
  23. width: 100%;
  24. height: 200px; // 固定高度
  25. position: relative;
  26. overflow: hidden;
  27. border: 1px solid #eee;
  28. margin-top: 20px;
  29. }
  30. </style>