webview.vue 1018 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <template>
  2. <view class="webview">
  3. <web-view :src="url" id="webcon" @message="handleMessage">
  4. </web-view>
  5. </view>
  6. </template>
  7. <script>
  8. export default {
  9. data() {
  10. return {
  11. url: '',
  12. device_id: '',
  13. accessToken: ''
  14. }
  15. },
  16. onLoad(options) {
  17. this.device_id = options.device_id
  18. this.accessToken = options.accessToken
  19. this.url = "https://wx.hnyfwlw.com/wechat?device_id=" + this.device_id + "&accessToken=" + this.accessToken
  20. //设置 webview 界面的状态栏的 title
  21. uni.setNavigationBarTitle({
  22. title: '监控详情'
  23. });
  24. },
  25. methods: {
  26. getWebviewPage(id) {
  27. this.url = "/static/h5.html?device_id=" + this.device_id + "&accessToken=" + this.accessToken
  28. //设置 webview 界面的状态栏的 title
  29. uni.setNavigationBarTitle({
  30. title: '监控详情'
  31. });
  32. },
  33. handleMessage(evt) {
  34. console.log('接收到的消息:' + JSON.stringify(evt.detail.data));
  35. }
  36. }
  37. }
  38. </script>
  39. <style>
  40. .webview {
  41. width: 100vw;
  42. height: 100vh;
  43. }
  44. </style>