因为IOS最新版微信取消了浮窗功能,小程序后台狠毒用户反馈进入不方便了,目前公众号还支持浮窗,于是需求出来了,浮窗一个H5,在H5中一键打开小程序,阅读文档得知,微信对公众号网页开发有开放标签,可以打开App或小程序,但是过程中遇到不少坑以下为记录爬坑。
1.正常操作,公众号后台绑定域名
2.引入weixin.js 目前是1.6.0版本
3.调用wx.config 在openTagList中加入要使用的开放标签
接下来坑来了,文档上使用示例如下
1 2 3 4 5 6 7 8 9 | .btn { padding: 12px } <button class = "btn" >打开小程序</button> var btn = document.getElementById( 'launch-btn' ); btn.addEventListener( 'launch' , function (e) { console.log( 'success' ); }); btn.addEventListener( 'error' , function (e) { console.log( 'fail' , e.detail); }); |
贴在vue中 无法使用,排查发现是template标签的问题
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | < div class = "center" style = "width: 100%" > .jump-btn { height: 44px; line-height: 44px; border: none; font-size: 16px; color: #ffffff; background-color: #f94048; text-align: center; } < div class = "jump-btn" >打开小程序 </ div > </ div > |