判断手机系统
function judgeSystem(){ var userAgent = navigator.userAgent; var index = userAgent.indexOf("Android") if(index >= 0){ androidVersion = parseFloat(userAgent.slice(index+8)); // console.log(androidVersion,'安卓版本') // if(androidVersion>=10){ // // 版本大于等于10 // } } }
获取当前版本号
function getAppVersion() { if (typeof nativeObject != "undefined") { if (window.nativeObject.getAppVersion) { // 安卓获取版本方式 var _version = window.nativeObject.getAppVersion(); return _version; } else { // IOS获取版本方式 var _version = window.nativeObject.handleMsgWithParam('getAppVersion', ''); return _version; } } else { return '0.0.0'; } }
判断手机类型
function judgeBrand(sUserAgent) { var isIphone = sUserAgent.match(/iphone/i) == "iphone"; var isHuawei = sUserAgent.match(/huawei/i) == "huawei"; var isHonor = sUserAgent.match(/honor/i) == "honor"; var isOppo = sUserAgent.match(/oppo/i) == "oppo"; var isOppoR15 = sUserAgent.match(/pacm00/i) == "pacm00"; var isVivo = sUserAgent.match(/vivo/i) == "vivo"; var isXiaomi = sUserAgent.match(/mi\s/i) == "mi "; var isXiaomi2s = sUserAgent.match(/mix\s/i) == "mix "; var isRedmi = sUserAgent.match(/redmi/i) == "redmi"; var isSamsung = sUserAgent.match(/sm-/i) == "sm-"; if (isIphone) { return 'iphone'; } else if (isHuawei || isHonor) { return 'huawei'; } else if (isOppo || isOppoR15) { return 'oppo'; } else if (isVivo) { return 'vivo'; } else if (isXiaomi || isRedmi || isXiaomi2s) { return 'xiaomi'; } else if (isSamsung) { return 'samsung'; } else { return 'default'; } } var brand = judgeBrand(navigator.userAgent.toLowerCase());
获取屏幕宽度
var windowWidth = $(window).width(); //根据不同屏幕宽度做不同处理 if(windowWidth<= 320){ //* }
到此这篇移动端相关信息获取的文章就介绍到这了,更多相关内容请继续浏览下面的相关推荐文章,希望大家都能在编程的领域有一番成就!
版权声明:
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若内容造成侵权、违法违规、事实不符,请将相关资料发送至xkadmin@xkablog.com进行投诉反馈,一经查实,立即处理!
转载请注明出处,原文链接:https://www.xkablog.com/yd-react-native/11169.html