• 企业400电话
  • 微网小程序
  • AI电话机器人
  • 电商代运营
  • 全 部 栏 目

    企业400电话 网络优化推广 AI电话机器人 呼叫中心 网站建设 商标✡知产 微网小程序 电商运营 彩铃•短信 增值拓展业务
    html5跳转小程序wx-open-launch-weapp踩坑

    因为IOS最新版微信取消了浮窗功能,小程序后台狠毒用户反馈进入不方便了,目前公众号还支持浮窗,于是需求出来了,浮窗一个H5,在H5中一键打开小程序,阅读文档得知,微信对公众号网页开发有开放标签,可以打开App或小程序,但是过程中遇到不少坑以下为记录爬坑。

    1.正常操作,公众号后台绑定域名
    2.引入weixin.js 目前是1.6.0版本
    3.调用wx.config 在openTagList中加入要使用的开放标签
    接下来坑来了,文档上使用示例如下

    <wx-open-launch-weapp
      id="launch-btn"
      username="gh_xxxxxxxx"
      path="pages/home/index.html?user=123&action=abc"
    >
      <template>
    <style>.btn { padding: 12px }</style>
    <button class="btn">打开小程序</button>
      </template>
    </wx-open-launch-weapp>
    <script> var btn = document.getElementById('launch-btn');
      btn.addEventListener('launch', function (e) {
    console.log('success');
      });
      btn.addEventListener('error', function (e) {
    console.log('fail', e.detail);
      }); </script> 
    

    贴在vue中 无法使用,排查发现是template标签的问题

    <div class="center" style="width: 100%" ref="launchBtnHome">
          <wx-open-launch-weapp id="launch-btn" username="gh_xxxxxxxx" path="pages/index/index/index" ref="launchBtn">
            <script type="text/wxtag-template">
              <style>
                .jump-btn {
                  height: 44px;
                  line-height: 44px;
                  border: none;
                  font-size: 16px;
                  color: #ffffff;
                  background-color: #f94048;
                  text-align: center;
                }
              </style>
              <div class="jump-btn">打开小程序</div>
            </script>
          </wx-open-launch-weapp>
        </div>
    

    这样基本功能就实现了,但是样式没法居中,在里面写的style很多不生效,最后解决方案是: 给开放标签外部套一个div 给div写样式,开放标签本身也可以通过ID选择器直接写样式, 至此开发完成,后续老板想在created中直接模拟点击按钮唤起小程序,试了ref获取dom后调用click方法可是不生效,发现论坛上也没有相关解决方案,微信开放社区中也有相关问题挂起并未解决,大家要是有什么好的方法可以下面讨论下一起解决下

    另附微信开放社区问题挂起的地址https://developers.weixin.qq.com/community/develop/doc/0004604a1d8df03099ba91c965b400

    到此这篇关于html5跳转小程序wx-open-launch-weapp踩坑 的文章就介绍到这了,更多相关html5跳转小程序内容请搜索脚本之家以前的文章或继续浏览下面的相关文章,希望大家以后多多支持脚本之家!

    上一篇:Bootstrap File Input文件上传组件
    下一篇:前端水印的简单实现代码示例
  • 相关文章
  • 

    © 2016-2020 巨人网络通讯

    时间:9:00-21:00 (节假日不休)

    地址:江苏信息产业基地11号楼四层

    《增值电信业务经营许可证》 苏B2-20120278

    html5跳转小程序wx-open-launch-weapp踩坑 html5,跳转,小,程序,wx-open-launch-weapp,