使用 navigator.userAgent
let userAgentInfo = navigator.userAgent
let agents = ['Android', 'iPhone', 'SymbianOS', 'Windows Phone', 'iPad', 'iPod', 'iOS']
let isPC = null
agents.forEach((item) => {
if (userAgentInfo.indexOf(item) > 0) {
isPC = false
return false
}
})
console.log(isPC)
网友评论