首页 > 技术文章 > 判断当前环境是ios还是安卓

huancheng 2019-08-07 15:40 原文

/**
 * @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
}

 

推荐阅读