JavaScript

判断移动端的系统是Andriod还是IOS

2018-09-27  本文已影响4人  Lia代码猪崽
// 判断移动端的系统
detectSystem(){
    let equipmentType = ''
    const agent = navigator.userAgent.toLowerCase()
    const android = agent.indexOf("android")
    const iphone = agent.indexOf("iphone")
    const ipad = agent.indexOf("ipad")
    if(android !== -1){
        equipmentType = "android"
    }
    if(iphone !== -1 || ipad !== -1){
        equipmentType = "ios";
    }
    return equipmentType;
}

参考资料

https://blog.csdn.net/qq_24147051/article/details/79131486

上一篇下一篇

猜你喜欢

热点阅读