vue3 中检测浏览器是否支持vue3 或是 浏览器不属于chorme内核
检测浏览器是否支持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.userAgent和navigator.vendor来获取浏览器信息,然后判断是否包含"Chrome"和"Google Inc"来判断是否属于Chrome内核。
原文地址: http://www.cveoy.top/t/topic/bxmb 著作权归作者所有。请勿转载和采集!