判断当前环境是ios还是安卓

/**
 * @name 判断iOS
 */
export const isiOS = ()=>{
    let u = navigator.userAgent;
    let iOs = !!u.match(/(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
    return iOs;
}
/**
 * @name 判断android
 */
export const isAndroid = ()=>{
    let u = navigator.userAgent;
    let android = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
    return android
}
原文地址:https://www.cnblogs.com/huancheng/p/11315688.html