H5页面添加按钮跳转小程序


使用微信开放标签: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']


 

  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