判断h5在小程序打开
作者:
kalrase | 来源:发表于
2019-11-07 17:54 被阅读0次1.h5页面下载:"weixin-js-sdk": "^1.0.0"
2.页面引入:import wx from 'weixin-js-sdk'
3.页面使用:
var ua = navigator.userAgent.toLowerCase();
if (ua.match(/MicroMessenger/i) == "micromessenger") {
// ios的ua中无miniProgram,但都有MicroMessenger(表示是微信浏览器)
wx.miniProgram.getEnv((res) => {
if (res.miniprogram) {
alert("在小程序里");
} else {
alert("不在小程序里");
}
})
} else {
alert('不在微信里');
}
4.小程序使用:<web-view src="http://localhost:8080/#/login"></web-view>
```
本文标题:判断h5在小程序打开
本文链接:https://www.haomeiwen.com/subject/kkgvbctx.html
网友评论