浏览器的分类

浏览器的分类

获取浏览器的类型

const MobileMatches: ReadonlyArray<string> = [
  'Needle',
  'Android',
  'Symbian',
  'UCWEB',
  'iPhone',
  'iPad',
  'iPod',
  'BlackBerry',
  'Windows Phone',
]

export default {
  isMobile() {
    let isMobile = false
    const ua = window.navigator.userAgent
    MobileMatches.forEach(name => {
      !isMobile && (isMobile = !!ua.match(new RegExp(`${name}`, 'i')))
    })
    return isMobile
  },

  isEBai() {
    const EBaiAppReg = /AliApp\(EB\//
    return EBaiAppReg.test(window.navigator.userAgent)
  },
}
const MobileMatches: ReadonlyArray<string> = [
  'Needle',
  'Android',
  'Symbian',
  'UCWEB',
  'iPhone',
  'iPad',
  'iPod',
  'BlackBerry',
  'Windows Phone',
]

export default {
  isMobile() {
    let isMobile = false
    const ua = window.navigator.userAgent
    MobileMatches.forEach(name => {
      !isMobile && (isMobile = !!ua.match(new RegExp(`${name}`, 'i')))
    })
    return isMobile
  },

  isEBai() {
    const EBaiAppReg = /AliApp\(EB\//
    return EBaiAppReg.test(window.navigator.userAgent)
  },
}

 

posted on 2021-06-06 21:56  漫思  阅读(45)  评论(0编辑  收藏  举报

导航