js判断当前登录的设备(pc还是移动)

 function checkDevice() {
        //userAgent 属性是一个只读的字符串,声明了浏览器用于 HTTP 请求的用户代理头的值
        const u = navigator.userAgent;
        //Android终端
        this.isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1;
        //iOS终端
        this.isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
      },

 

posted @ 2020-08-03 10:32  叶子0321~  阅读(415)  评论(0编辑  收藏  举报