前端如何判断用户的电脑是 arm 还是 x86?-灵析社区

九久九

navigator.userAgentData.getHighEntropyValues(["architecture", "bitness"]) .then(ua => { if (navigator.userAgentData.platform === "Windows") { if (ua.architecture === 'x86') { if (ua.bitness === '64') { console.log("x86_64"); } else if (ua.bitness === '32') { console.log("x86"); } } else if (ua.architecture === 'arm') { if (ua.bitness === '64') { console.log("ARM64"); } else if (ua.bitness === '32') { console.log("ARM32"); } } } else { console.log("Not running on Windows"); } }); ![image.png](https://wmlx-new-image.oss-cn-shanghai.aliyuncs.com/images/20241104/028eef6e73db27dc55877a00ef69e966.png) 微软官方文档: > [https://learn.microsoft.com/zh-cn/microsoft-edge/web-> platform...](https://link.segmentfault.com/?enc=OBvQP6iTGTGoFk%2Fhyc%2F8gA%3D%3D.DxsrQydkCcoqAt8B1XeyzCVFEvbUAYvSpcZ0OHPpcT5rhwFgvGV76DTeWG%2Bty6uiiqzLE6DJyuvivUMNlxkPosH0Ifz80UzVwTl%2BVAP3o6eswPl5MwK5JmnXb%2FSrsFuY) 截图中的用浏览器api就可以获取 navigator.userAgent; ![image.png](https://wmlx-new-image.oss-cn-shanghai.aliyuncs.com/images/20241104/2f21bd84d7018695f379a255db1a01be.png)

阅读量:1

点赞量:0

问AI