//一
let agent = navigator.userAgent.toLowerCase();
let android = agent.indexOf("android");
let iphone = agent.indexOf("iphone");
let ipad = agent.indexOf("ipad");
if (android != -1) {
console.log('android')
}
if (iphone != -1 || ipad != -1) {
console.log('ios')
}
//二
let u = navigator.userAgent;
let isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //android终端或者uc浏览器
let isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
来源:CSDN
作者:Boss灬Ming
链接:https://blog.csdn.net/wang993828743/article/details/103973579