MtaPDF.vue 712 B

12345678910111213141516171819202122232425262728293031323334
  1. <template>
  2. <view class="pdf-container" v-if="pdfUrl" >
  3. <template v-if="systemInfo.platform == 'android'">
  4. <web-view
  5. :src="pdfUrl1"
  6. class="web-view"></web-view>
  7. </template>
  8. <template v-else>
  9. <web-view :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. const pdfUrl1 = `/hybrid/html/web/viewer.html?file=${encodeURIComponent(props.pdfUrl)}`
  21. </script>
  22. <style lang="scss">
  23. .pdf-container {
  24. width: 100%;
  25. height: 200px; // 固定高度
  26. position: relative;
  27. overflow: hidden;
  28. border: 1px solid #eee;
  29. margin-top: 20px;
  30. }
  31. </style>