index.vue 891 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <!-- pages/admin/webview/index.vue -->
  2. <template>
  3. <view class="webview-container">
  4. <!-- #ifndef H5 -->
  5. <web-view :src="url" @load="onLoad" @message="onMessage"></web-view>
  6. <!-- #endif -->
  7. <!-- #ifdef H5 -->
  8. <iframe :src="url" style="width:100%;height:100vh;border:none;"></iframe>
  9. <!-- #endif -->
  10. </view>
  11. </template>
  12. <script setup>
  13. import { ref } from 'vue';
  14. import { onLoad as onPageLoad } from '@dcloudio/uni-app';
  15. const url = ref('');
  16. onPageLoad((options) => {
  17. if (options.url) {
  18. url.value = decodeURIComponent(options.url);
  19. }
  20. });
  21. const onLoad = (e) => {
  22. console.log('webview loaded', e);
  23. };
  24. const onMessage = (e) => {
  25. console.log('message from webview', e.detail.data);
  26. };
  27. function goUpPage() {
  28. uni.redirectTo({
  29. url: `/pages/admin/ShouYe/shouye`
  30. })
  31. }
  32. </script>
  33. <style>
  34. .webview-container {
  35. width: 100%;
  36. height: 100vh;
  37. }
  38. </style>