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