关于前端:微信内h5跳转小程序

8次阅读

共计 657 个字符,预计需要花费 2 分钟才能阅读完成。

最近有一个需要,微信内 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….

正文完
 0