webview.vue 555 B

1234567891011121314151617181920212223242526272829
  1. <template>
  2. <view class="container">
  3. <web-view :src="fileUrl" :title="pageTitle"></web-view>
  4. </view>
  5. </template>
  6. <script setup>
  7. import { ref } from 'vue'
  8. import { onLoad } from '@dcloudio/uni-app'
  9. const fileUrl = ref('')
  10. const pageTitle = ref('文件预览')
  11. onLoad((options) => {
  12. fileUrl.value = options.url || ''
  13. pageTitle.value = options.title || '文件预览'
  14. // 设置导航栏标题
  15. uni.setNavigationBarTitle({
  16. title: pageTitle.value
  17. })
  18. })
  19. </script>
  20. <style scoped>
  21. .container {
  22. width: 100%;
  23. height: 100vh;
  24. }
  25. </style>