码迷,mamicode.com
首页 > 移动开发 > 详细

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

时间:2019-08-07 15:59:02      阅读:144      评论:0      收藏:0      [点我收藏+]

标签:oid   and   div   终端   ||   isa   nbsp   match   mac os x   

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

 

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

标签:oid   and   div   终端   ||   isa   nbsp   match   mac os x   

原文地址:https://www.cnblogs.com/huancheng/p/11315688.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!