最近有一个需要,微信内h5跳转小程序,扒了扒微信社区,才晓得5月份不吭不响的上线了能够实现跳转h5的标签,话不多说,上代码
<wx-open-launch-weapp v-if="weChat" id="launch-btn" username="gh_xxxxxxxxx" path="/a/b/c.html" @error="handleErrorFn" @launch="handleLaunchFn"> <template> <script type="text/wxtag-template"> <div style='position:relative'> <div style="text-align:center;"><button class="wx-btn">点击跳转小程序</button></div> </div> </script> </template> </wx-open-launch-weapp>
handleErrorFn(e) { console.log("fail", e.detail) }, handleLaunchFn(e) { console.log("success") }
username为小程序原始id,path为小程序的页面门路,
切记,须要引入1.6版本的sdk,在须要调用JS接口的页面引入如下JS文件:http://res.wx.qq.com/open/js/... (反对https)
本篇介绍的是vue的语法调用,如其余框架请参照微信凋谢文档即可
https://developers.weixin.qq....