Loading

uni-app 判断客户端环境是安卓还是ios

https://www.jianshu.com/p/a36d9e771b00

App、H5和微信小程序判断是安卓还是ios

switch(uni.getSystemInfoSync().platform){
    case 'android':
       console.log('运行Android上')
       break;
    case 'ios':
       console.log('运行iOS上')
       break;
    default:
       console.log('运行在开发者工具上')
       break;
}
注:在微信小程序开发工具中使用 uni.getSystemInfoSync().platform返回值为 devtools

H5判断是安卓还是ios

//判断是安卓还是ios
isAndroidOrIOS() {
    var u = navigator.userAgent;
    var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
    var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
    if (isAndroid) {
        return "1"
    }
    if (isiOS) {
        return "0"
    }
}

 

posted @ 2021-11-17 13:56  5572  阅读(845)  评论(0编辑  收藏  举报