微信内h5跳转小程序
文章目录
最近有一个需求,微信内h5跳转小程序,扒了扒微信社区,才知道5月份不吭不响的上线了可以实现跳转的标签,话不多说,上代码
<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,并通过wx.config注入权限方可使用,具体如何注入参照微信文档jssdk(https://developers.weixin.qq....)在需要调用JS接口的页面引入如下JS文件:http://res.wx.qq.com/open/js/... (支持https)
本篇介绍的是vue的语法调用,如其他框架请参照微信开放文档即可
https://developers.weixin.qq....
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论