webview.vue 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 = "/static/h52.html?device_id=" + this.device_id + "&accessToken=" + this.accessToken
  20. // uni.setStorage({
  21. // key: 'obj',
  22. // data: JSON.stringify({
  23. // device_id: this.device_id,
  24. // accessToken: this.accessToken
  25. // })
  26. // })
  27. //设置 webview 界面的状态栏的 title
  28. uni.setNavigationBarTitle({
  29. title: '监控详情'
  30. });
  31. // this.getWebviewPage()
  32. },
  33. methods: {
  34. getWebviewPage(id) {
  35. this.url = "/static/h5.html?device_id=" + this.device_id + "&accessToken=" + this.accessToken
  36. // uni.setStorage({
  37. // key: 'obj',
  38. // data: JSON.stringify({
  39. // device_id: this.device_id,
  40. // accessToken: this.accessToken
  41. // })
  42. // })
  43. //设置 webview 界面的状态栏的 title
  44. uni.setNavigationBarTitle({
  45. title: '监控详情'
  46. });
  47. },
  48. handleMessage(evt) {
  49. console.log('接收到的消息:' + JSON.stringify(evt.detail.data));
  50. }
  51. }
  52. }
  53. </script>
  54. <style>
  55. .webview {
  56. width: 100vw;
  57. height: 100vh;
  58. }
  59. </style>