zyt-it

1.话不多说直接上代码,已使用有效

<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
<script>
    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(\'不在微信里\');
    }
</script>

来源:https://www.cnblogs.com/daipianpian/p/10288675.html

分类:

技术点:

相关文章:

  • 2021-11-04
  • 2021-11-15
  • 2021-11-21
  • 2021-11-18
  • 2021-12-14
  • 2021-11-07
  • 2021-12-04
  • 2021-08-04
猜你喜欢
  • 2021-11-30
  • 2020-10-14
  • 2021-08-01
  • 2021-12-04
  • 2021-11-20
  • 2021-11-08
  • 2021-11-18
相关资源
相似解决方案