const isAndroid=()=> {
const u = navigator.userAgent;
if (u.indexOf('Android') > -1 || u.indexOf('Linux') > -1) {
return true;
}
return false;
}
然后在需要判断的地方直接调用就可以了
举例
if(isAndroid()){
// 需要进行安卓的操作
}else{
//ios操作
}