wx-open-launch-weapp H5跳转到微信小程序

刚好项目有个需求H5跳转到微信小程序,今天尝试一下:
1、引入https://res.wx.qq.com/open/js/jweixin-1.6.0.js*(注意要用jweixin-1.6.0.js,低版本不支持,这里掉坑了)*
2、vue项目需要在main.js加上

 Vue.config.ignoredElements = ['wx-open-launch-weapp']

3、注册config

let wxConfig = {} //获取从后台传回来的
    WX.config({
      debug: false,
      appId: wxConfig.appId,
      timestamp: wxConfig.timestamp,
      nonceStr: wxConfig.nonceStr,
      signature: wxConfig.signature,
      jsApiList: ['wx-open-launch-weapp'], // 必填,需要使用的JS接口列表
      openTagList: ['wx-open-launch-weapp'] // 可选,需要使用的开放标签列表,例如['wx-open-launch-app']
    }) 

4、页面加跳转

    <wx-open-launch-weapp
      id="launch-btn"
      username="gh_c6c35a7c7e4a"
      path="/pages/detail/activityDetail/index.html?id=2124&type=0"
      @error="handleErrorFn"
      @launch="handleLaunchFn"
    >
    <!-- 
    注意:
    path结尾注意不要漏了.html
    username:需要用到原始id   而不是appid
    vue中需要使用script标签代替template插槽 html中使用template 
    -->
      <script type="text/wxtag-template">
        <p class="store-tool_tip">点击进入小程序</p>
      </script>
    </wx-open-launch-weapp>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值