webview.uvue 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <!-- 网络链接内容展示页(用于uni-cms-article展示外链内容) -->
  2. <template>
  3. <view class="web-view">
  4. <web-view
  5. class="web-view"
  6. v-if="url"
  7. :src="url"
  8. ></web-view>
  9. </view>
  10. </template>
  11. <script lang="uts">
  12. export default {
  13. onLoad(e) {
  14. const url = e.get('url') as string
  15. let title: string | null = e.get('title')
  16. if (url.substring(0, 4) != 'http') {
  17. uni.showModal({
  18. title: "错误",
  19. content: '不是一个有效的网站链接,' + '"' + decodeURIComponent(url) + '"',
  20. showCancel: false,
  21. confirmText: "知道了",
  22. complete: () => {
  23. uni.navigateBack()
  24. }
  25. })
  26. title = "页面路径错误"
  27. } else {
  28. this.url = decodeURIComponent(url)
  29. }
  30. if (title != null) {
  31. uni.setNavigationBarTitle({title})
  32. }
  33. },
  34. data() {
  35. return {
  36. url: null as string | null,
  37. }
  38. }
  39. }
  40. </script>
  41. <style>
  42. .web-view {
  43. height: 100%;
  44. }
  45. </style>