js 判断浏览器UA

2020-12-24 00:00:00 by 【6yang】, 252 visits, 收藏 | 返回
const ua = navigator.userAgent
 
//浏览器环境判断
export let OS = (() => {
  let isWeixin = /(?:micromessenger)/i.test(ua),
    isAndroid = /(?:Android)/i.test(ua),
    isIPhone = /(?:iPhone)/i.test(ua),
    isiPad = /(?:iPad)/i.test(ua),
    isPc = !isIPhone && !isAndroid
  return {
    isWeixin,
    isIOS: isiPad || isIPhone,
    isAndroid,
    isPc
  }
})()
 
分享到:
share

    图片原图

    loading

    loading