收藏
回答

wx-open-launch-app 标签内容无法渲染?

// 真实的appid用XX代替
<div class="wx-opens" id="wxOpenInAPP">
    <wx-open-launch-app
        :id="wx_id"
        class="launch-btn"
        appid="XXXXXXX"
        extinfo=""
        >
        <script type="text/wxtag-template">
            <style>
                .open-app{
                    padding: 5px 15px;
                    color: #F35119;
                    background-color: #fff;
                    border-radius: 5px;
                }
            </style>
            <div class="open-app">打开</div>
        </script>
    </wx-open-launch-app>
</div>


// 通过接口获取配置数据
wx.config({
    beta: true, // 开启内测接口调用,注入wx.invoke方法
    debug: false, // 开启调试模式
    appId: res.data.appid, // 第三方app唯一标识
    timestamp: res.data.timestamp, // 生成签名的时间戳
    nonceStr: res.data.noncestr, // 生成签名的随机串
    signature: res.data.signature, // 签名
    jsApiList: ["chooseImage", "uploadImage"], // 需要使用的jsapi列表,所有jsapi列表见附录2
    openTagList: ['wx-open-launch-app']
});

wx.error(function (res) {
    console.log('微信错误',res)
});

let btn = document.getElementById(this.wx_id);
btn.addEventListener('launch', e => {
    console.log('success');
});
btn.addEventListener('error',  e => {
    console.log('fail', e.detail);
});


mounted() {
   // 导入微信jssdk
  let script = document.createElement('script');
  script.setAttribute("type", "text/javascript");
  script.setAttribute("src", "https://res.wx.qq.com/open/js/jweixin-1.6.0.js");
  document.body.appendChild(script);
}


用Vue-cli2 打包后上线wx-open-launch-app里面无法渲染,官方是说用<script type="text/wxtag-template">,但现象是里面的内容无法渲染出来,

也没用任何报错提醒

我尝试过做一个demo走template渲染,不用vue框架是可以正常的,但是<script type="text/wxtag-template">为什么不行?

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

3 个回答

  • ipeng
    ipeng
    2021-02-24

    请问楼主解决了吗?我的url带上参数,签名就会无效,去掉?后面的部分就能成功。

    2021-02-24
    有用
    回复
  • 半橙汁
    半橙汁
    2020-09-14

    楼主,直接v-html 还是渲染不出来,请问是我哪里写错了吗?求教ing~

    2020-09-14
    有用
    回复 1
    • serendipity
      serendipity
      2021-12-03
      请问后来你做出来了吗?我现在就是你这样做的
      2021-12-03
      回复
  • 睡前原谅一切
    睡前原谅一切
    2020-07-15

    服务号appId正确吗?不是个人测试号吧?

    2020-07-15
    有用
    回复 6
    • 哎呀!我摔倒了!
      哎呀!我摔倒了!
      2020-07-15
      appId是正确的,问题已经找到了,感谢回答,我在问题找到之前发现了,用js创建标签去注入div里也是能走通的(可以直接写template)
      2020-07-15
      回复
    • 睡前原谅一切
      睡前原谅一切
      2020-07-15回复哎呀!我摔倒了!
      666
      2020-07-15
      回复
    • 小蜜蜂
      小蜜蜂
      2020-10-30回复哎呀!我摔倒了!
      请问楼主最后怎么解决的这里
      2020-10-30
      回复
    • mG
      mG
      2020-11-20回复哎呀!我摔倒了!
      請問樓主後面是怎麼解決的,v-html + template嗎,是不是沒有用script type=text/wxtag-template>
      2020-11-20
      回复
    • 哎呀!我摔倒了!
      哎呀!我摔倒了!
      2020-11-29回复mG
      是没有用script type=text/wxtag-template>,最后是只用template,只不过是在页面完全渲染之后再去配置wx.config
      2020-11-29
      回复
    查看更多(1)
登录 后发表内容
问题标签