浏览器类型以及版本判断

export function getBrowserType() {
  const ret = {}
  const ua = navigator.userAgent.toLowerCase()
  const bro = []

  if (navigator.appVersion.match(/MSIE 6./i) === '6.') {
    ret.type = 'IE'
    ret.version = 6
    return ret
  }
  bro.push(ua.match(/msie ([\d.]+)/))
  bro.push(ua.match(/firefox\/([\d.]+)/))
  bro.push(ua.match(/chrome\/([\d.]+)/))
  bro.push(ua.match(/opera.([\d.]+)/))
  bro.push(ua.match(/version\/([\d.]+).*safari/))


  bro.map((value) => {
    if (value) {
      [ret.type, ret.version] = value
    }
    return false
  })
  return ret
}

export const lowLimit = {
  safari: 11,
  chrome: 66,
  firefox: 60,
  edge: 17,
}

你可能感兴趣的:(浏览器类型以及版本判断)