从Chrome 103开始navigator.userAgent
只能获取到主版本号了。以下代码通过User-Agent Client Hints API获取完整版本号:
const uaValues = await navigator.userAgentData.getHighEntropyValues(['fullVersionList'])
const fullVersion = uaValues.fullVersionList.find(entry=>entry.brand='Google Chrome').version
console.log(fullVersion)
参考
https://developer.mozilla.org/en-US/docs/Web/HTTP/Client_hints