js常用工具函数之浏览器平台判断方法
查看vue2源码:src\core\util\env.js
// Browser environment sniffing
//是否浏览器
export const inBrowser = typeof window !== 'undefined'
//是否weex
export const inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform
export const weexPlatform = inWeex && WXEnvironment.platform.toLowerCase()
export const UA = inBrowser && window.navigator.userAgent.toLowerCase()
//是否IE
export const isIE = UA && /msie|trident/.test(UA)
//是否IE9
export const isIE9 = UA && UA.indexOf('msie 9.0') > 0
//是否Edge
export const isEdge = UA && UA.indexOf('edge/') > 0
//是否Android
export const isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android')
//是否IOS
export const isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios')
//是否Chrome
export const isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge
//是否无核浏览器PhantomJS
export const isPhantomJS = UA && /phantomjs/.test(UA)