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/);
      },
原文地址:https://www.cnblogs.com/zhangyezi/p/13424910.html