js 判断客户端
2019-12-06 本文已影响0人
草帽lufei
使用 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)