微信公众号Html5页面跳转微信小程序wx-open-launch-weapp

注意事项:

  1. weixin-js-sdk版本一定要是1.6.0以上:"weixin-js-sdk": "^1.6.0"

  2. H5的域名ip需要配置的微信公众平台后台系统的白名单中

  3. wx.config的jsApiList必须有一个

  4. wx.config的openTagList为["wx-open-launch-weapp"] 注意后边是weapp而非app

  5. 引入import wx from "weixin-js-sdk"

  6. 正式环境调试,微信开发者工具让它滚蛋~

  7. 代码如下,懒得排版了:

    <div class="jump">
        <div class="pos">
          <div class="wxbtn">
            <!-- ct为按钮显示的图片 wx-open-launch-weapp的button按钮为opacity:0 absolute -->
            <div class="ct"></div>
            <div>
              <wx-open-launch-weapp
                style="
                  position: absolute;
                  top: 0;
                  left: 0;
                  width: 100%;
                  height: 100%;
                  display: inline-block;
                  border: none;
                "
                username="gh_xxxxxxxx"
                appid="wx111111111111"
                path="xxx/index"
              >
                <script type="text/wxtag-template">
                  <style>
                      .btn {
                          position: absolute;
                          top: 0;
                          left: 0;
                          width: 100%;
                          height: 100%;
                          opacity: 0;
                      }
                  </style>
                  <button class="btn"></button>
                </script>
              </wx-open-launch-weapp>
            </div>
          </div>
        </div>
      </div>
    
    wx.config({
                debug: false, // 开启调试模式,
                appId: res.data.jsigParam.appId, // 必填,企业号的唯一标识,此处填写企业号corpid
                timestamp: res.data.jsigParam.timestamp, // 必填,生成签名的时间戳
                nonceStr: res.data.jsigParam.noncestr, // 必填,生成签名的随机串
                signature: res.data.jsigParam.signature, // 必填,签名,见附录1
                jsApiList: ["updateTimelineShareData"], // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
                openTagList: ["wx-open-launch-weapp"],
              });
    
    
    .jump {
      width: 100%;
      height: 100%;
      background: url("../../assets/bg.png") no-repeat;
      background-size: 100% 100%;
      position: relative;
    }
    
    .pos {
      width: 36.3125rem * 0.5;
      height: 8.5625rem * 0.5;
      position: absolute;
      left: 50%;
      transform: translate(-50%);
      bottom: 6.5rem;
    }
    
    .wxbtn {
      width: 36.3125rem * 0.5;
      height: 8.5625rem * 0.5;
      line-height: 8.5625rem * 0.5;
      text-align: center;
      color: #ffffff;
      font-weight: 500;
      position: relative;
      .ct {
        width: 100%;
        height: 100%;
        background: url("../../assets/btn.png") no-repeat;
        background-size: 100% 100%;
      }
    }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值