检测浏览器是否支持 Vue3 可以使用以下代码:

if (typeof window !== 'undefined' && window.Vue && window.Vue.version.startsWith('3.')) {
  // 浏览器支持 Vue3
} else {
  // 浏览器不支持 Vue3
}

要检测浏览器是否不属于 Chrome 内核,可以使用以下代码:

const isChrome = /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor);
if (!isChrome) {
  // 浏览器不属于 Chrome 内核
}

这里使用了navigator.userAgentnavigator.vendor来获取浏览器信息,然后判断是否包含'Chrome'和'Google Inc'来判断是否属于 Chrome 内核。

Vue3 浏览器兼容性检测:支持 Vue3 和 Chrome 内核判断

原文地址: https://www.cveoy.top/t/topic/m1iX 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录