H5页面添加按钮跳转小程序
时间:2021-06-02 20:14:25
收藏:0
阅读:0
使用微信开放标签:wx-open-launch-weapp;
username:务必是gh_开头的小程序原始id
path:跳转小程序的地址及参数
务必需要引用http://res2.wx.qq.com/open/js/jweixin-1.6.0.js
JSSDK需要配置:openTagList:[‘wx-open-launch-weapp‘]
<wx-open-launch-weapp id="launch-btn" username="gh_XXXXXXXXXXX" path="pages/index/index?scene=7736_2316486_0_0" > <script type="text/wxtag-template"> ----您的按钮内容----- </script> </wx-open-launch-weapp>
var btn = document.getElementById(‘launch-btn‘); btn.addEventListener(‘launch‘, function (e) { console.log(‘success‘); }); btn.addEventListener(‘error‘, function (e) { console.log(‘fail‘, e.detail); });
参考:
https://blog.csdn.net/xyphf/article/details/115193299
评论(0)