uniapp --->webview 使用,和H5页面通信

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
小程序页面<br><br><web-view  src="http://172.20.10.3:8080/#/information" @message="getMessage" ></web-view>
 
 
methods:{
    getMessage(event) {<br>          // 跳转别的小程序
               my.navigateToMiniProgram({
                     appId: '2021002170600786',
                     // path: 'pages/index/index',
                     extraData:{
                       "data1":"test"
                     },
                     success: (res) => {
                       console.log(JSON.stringify(res))
                     },
                     fail: (res) => {
                       console.log(JSON.stringify(res))
                     }
                   });
            },
 
 
}

  

1
2
3
4
5
6
7
H5页面
 <script type="text/javascript" src="https://appx/web-view.min.js"></script>
  <script>
    if (navigator.userAgent.indexOf('AliApp') > -1) {
      document.writeln('<script src="https://appx/web-view.min.js"' + '>' + '<' + '/' + 'script>');
    }
  </script><br><br>
     my.postMessage({name:"测试web-view"});

  

posted @   不服憋着  阅读(277)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 如何调用 DeepSeek 的自然语言处理 API 接口并集成到在线客服系统
· 【译】Visual Studio 中新的强大生产力特性
· 2025年我用 Compose 写了一个 Todo App
点击右上角即可分享
微信分享提示