收藏
回答

wx-open-launch-weapp 标签内容没有展示

https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/Wechat_Open_Tag.html

这里有有个自定义的h5页面,需要跳转小程序,页面使用 wx-open-launch-weapp 标签,标签内内容无法展示

<wx-open-launch-weapp id="launch-btn" username="gh_cbcf7737c7f4" path="/pages/index/index">
    <script type="text/wxtag-template">
        <style>.btn { padding: 12px }</style>
        <button class="btn">打开小程序</button>
    </script>
</wx-open-launch-weapp>


<script type="text/javascript">
    alert(location.href.split('#')[0]);
    document.addEventListener('WeixinOpenTagsError', function (e) {
        console.error(e.detail.errMsg); // 无法使用开放标签的错误原因,需回退兼容。仅无法使用开放标签,JS-SDK其他功能不受影响
    });
    $.ajax({
        url :"/config",
        type: 'get',
        dataType: 'text',
        success:function (res) {
            var data = JSON.parse(res);
            wx.config({
                debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印
                appId: data.data.appId, // 必填,公众号的唯一标识
                timestamp: data.data.timestamp, // 必填,生成签名的时间戳
                nonceStr: data.data.nonceStr, // 必填,填任意非空字符串即可
                signature: data.data.signature, // 必填,填任意非空字符串即可
                jsApiList: data.data.jsApiList, // 必填,随意一个接口即可
                openTagList: ['wx-open-launch-weapp'] // 填入打开小程序的开放标签名
            });
            var btn = document.getElementById('launch-btn');
            btn.addEventListener('launch',function (e) {
                console.log("success");
            });
            btn.addEventListener("error",function (e) {
                console.log("fail",e.detail);
            });
            wx.ready(function (data) {
                console.log("ready",data);
            });
            wx.error(function () {
                console.log("err");
            });
        }
    });
</script>


接口回调返回正常,页面始终无法展示 wx-open-launch-weapp 标签内容,https://m-test.sensorexpert.com.cn/forum 该链接在 微信内打开 也无法显示标签内容


回答关注问题邀请回答
收藏

2 个回答

  • 蓝色
    蓝色
    2023-04-21

    大佬,你解决了这个问题没? 我配置了https之后"wx-open-launch-weapp"这个标签就失效了,但是http访问的时候就正常。

    2023-04-21
    有用
    回复
  • Jianbo
    Jianbo
    2022-12-12

    可以显示呀


    2022-12-12
    有用
    回复 11
    查看更多(6)
登录 后发表内容