因为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