cre-ua-parser
v1.1.3
Published
cre-ua-parser
Downloads
46
Keywords
Readme
cre-ua-parser 客户端类型判断
Install
npm i cre-ua-parser
# or
yarn add cre-ua-parser
Usage
import {
getParser,
getOsObj,
isAndroid,
isIOS,
getOsStr,
getBrowserName
} from 'cre-ua-parser'
// 不传ua时,默认取navigator.userAgent
/**
* 获取客户端信息对象
* @param {String} ua userAgent字符串
* @return {Object}
*/
getParser(ua)
/**
* 获取系统信息对象
* @param {String} ua userAgent字符串
*/
getOsObj(ua)
/**
* 是否是安卓设备
* @param {String} ua userAgent字符串
* @return {Boolean}
*/
isAndroid(ua)
/**
* 是否是IOS设备
* @param {String} ua userAgent字符串
* @return {Boolean}
*/
isIOS(ua)
/**
* 获取系统信息字符串
* @param {String} ua userAgent字符串
* @return {String} name version
*/
getOsStr(ua)
/**
* 获取当前userAgent浏览器名称
* @author wangAlen
* @description 2020-10-13 10:03
* @description 通过getBrowserName === 'ie' 判断当前是否为ie内核浏览器,包括ie11、ie10、其他ie
* @param {Object} userAgent 当前网页userAgent对象
* @returns {String} 浏览器名称
*/
getBrowserName(userAgent)