1、判断是否是浏览器
const inBrowser = typeof window !=='undefined' && Object.prototype.toString.call(window) !== '[object Object]';
2、下面判断用到的几个变量
判断是不是Weex环境
const inWeex =typeof WXEnvironment !== 'undefined' &&!!WXEnvironment.platform
判断是Weex的那个版本
const weexPlatform = inWeex && WXEnvironment.platform.toLowerCase();
获取浏览器的userAgent
const UA = inBrowser && window.navigator.userAgent.toLowerCase()
3、关于IE浏览器的判断
const isIE = UA && /msie|trident/.test(UA);
const isIE9 = UA && UA.indexOf('msie 9.0') > 0;
const isEdge = UA && UA.indexOf('edge/') > 0;
4、关于安卓和IOS的判断
const isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android');
const isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios');
5、是否是谷歌浏览器
const isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
6、判断是否为微信
const isWechat = UA && UA.indexOf('micromessenger') > 0
注:该知识点参考了Vue源码