收藏
回答

h5跳转小程序按钮不出来,wx-open-launch-weapp 为什么不出来?

<script src="https://fastly.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>


 wx.config({
debug:true,
    appId: config.appId,
    timestamp:Number(config.timestamp),
    nonceStr:config.nonceStr,
    signature:config.signature,
    jsApiList: [
      'checkJsApi', 'onMenuShareAppMessage',
    ],
    openTagList: ['wx-open-launch-weapp'],
  })
  wx.ready(function () {
    wx.checkJsApi({
      jsApiList: ['chooseImage','updateAppMessageShareData','updateTimelineShareData'],
      success: function(res) {
        if(res.errMsg=='checkJsApi:ok'){
          console.log('xxxxxxxxxx',res)
        }
      }
    });
  });



<body>
  <wx-open-launch-weapp id="launch-btn" username="gh_ad28b62582b8" path="/pages/user/index">
    <script type="text/wxtag-template" slot="style">
      <style>.btn { padding: 12px;color:red }</style>
      <button class="btn">打开小程序</button>
    </script>
  </wx-open-launch-weapp>
  <script>
    var btn = document.getElementById('launch-btn');
    btn.addEventListener('launch', function (e) {
      console.log('success');
    });
    btn.addEventListener('error', function (e) {
      console.log('fail', e.detail);
    });
  </script>
</body>




最后一次编辑于  2022-08-19
回答关注问题邀请回答
收藏
登录 后发表内容