• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

微信公众号跳转小程序方法

武飞扬头像
程序媛刘刘
帮助1

1 公众号需要关联小程序

2 跳转方法:

  1.  
    wx.navigateToMiniProgram({
  2.  
    appId: '', //微信小程序appid
  3.  
    path: 'page/index/index?id=123', //打开的小程序页面
  4.  
    extraData: {
  5.  
    foo: 'bar' //传递的数据
  6.  
    },
  7.  
    envVersion: 'develop', //打开的小程序版本
  8.  
    success(res) {
  9.  
    // 打开成功
  10.  
    }
  11.  
    })
  1.  
    <wx-open-launch-weapp
  2.  
    id="launch-btn"
  3.  
    username="gh_xxxxxxxx" //小程序的原始id,在微信公众号--设置--基础设置--账号信息
  4.  
    path="pages/home/index?user=123&action=abc" //跳转的页面路径和参数
  5.  
    >
  6.  
    <script type="text/wxtag-template">
  7.  
    <style>.btn { padding: 12px }</style>
  8.  
    <button class="btn">打开小程序</button>
  9.  
    </script>
  10.  
    </wx-open-launch-weapp>
  11.  
    <script>
  12.  
    var btn = document.getElementById('launch-btn');
  13.  
    btn.addEventListener('launch', function (e) {
  14.  
    console.log('success');
  15.  
    });
  16.  
    btn.addEventListener('error', function (e) {
  17.  
    console.log('fail', e.detail);
  18.  
    });
  19.  
    </script>
学新通
  • a标签
  1.  
    <a href="http://www.qq.com" data-miniprogram-appid="appid" data-miniprogram-path="pages/index/index">点击跳小程序</a>
  2.  
     
  3.  
    data-miniprogram-appid 跳转的小程序appid
  4.  
    data-miniprogram-path 跳转的小程序页面

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhgbjgca
系列文章
更多 icon
同类精品
更多 icon
继续加载