H5识别小程序码以及H5点击跳转小程序

首先共通先要调用

<script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>

识别小程序码

config中加入wx-open-launch-app

function configJs(timestamp,nonceStr,signature){
    wx.config({
        debug: false,
        appId: 'xxxxx',
        timestamp: timestamp,
        nonceStr: nonceStr,
        signature: signature,
        jsApiList: [ 'checkJsApi', 'scanQRCode', 'onMenuShareTimeline', 'onMenuShareAppMessage'],
        openTagList: ['wx-open-launch-app']
    });
    wx.error(function(res){
        //alert(res.errMsg);
    });
}

html

<wx-open-launch-weapp 
   id="launch-btn"
   username="gh_xxxxxx"
   path="pages/index/index">
      <img src="xxxxxx" alt=""/>
</wx-open-launch-weapp>

点击图片或btn跳转小程序页面

这个方法首先h5是要在web-biew情况下才能用

直接在h5上添加事件就行

$('.xx').click(function(){
   wx.miniProgram.navigateTo({url: '/pages/index/index'})
})

发表评论

电子邮件地址不会被公开。