var userAgent = window.navigator.userAgent
export default {
isFromAndroid: /android/gi.test(userAgent), /* 安卓*/
isFromIOs: /iphone|ipod|ios/gi.test(userAgent), /* IOS */
isFromWeChat: /MicroMessenger/gi.test(userAgent), /* 微信 */
isFromQQ: /mobile.*qq/gi.test(userAgent), /* QQ */
isFromUC: /ucbrowser/gi.test(userAgent),/* UC浏览器 */
isFromQQBrowser: /mqqbrowser[^LightApp]/gi.test(userAgent),/* QQ浏览器 */
isFromQQBrowserLight: /MQQBrowserLightApp/gi.test(userAgent),/* qq轻浏览器*/
isTrident: /Trident/gi.test(userAgent), /**IE内核 */
isPresto: /Presto/gi.test(userAgent), /** opera内核 */
iswebKit: /AppleWebKit/gi.test(userAgent), /** 苹果、谷歌内核 */
isGecko: /Gecko.*KHTML/gi.test(userAgent), /** 火狐内核 */
isMobile: !!userAgent.match(/AppleWebKit.*Mobile.*/),/**是否为移动终端 */
isIos: !!userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), /* ios终端 */
isAndroid: userAgent.indexOf('Android') > -1 || u.indexOf('Adr') > -1, //android终端
isIPhone: userAgent.indexOf('iPhone') > -1, //iPhone或者QQHD浏览器
isIPad: userAgent.indexOf('iPad') > -1, //iPad
isWebApp: userAgent.indexOf('Safari') == -1, //web应该程序,没有头部与底部
}
使用
(navigator.browserLanguage || navigator.language).toLowerCase()