优化对移动设备的识别
This commit is contained in:
parent
90fc0ef7e8
commit
1f36630a34
@ -1 +1 @@
|
||||
3.9.43beta5
|
||||
3.9.43beta6
|
||||
@ -21,10 +21,11 @@
|
||||
function isPhone() {
|
||||
//获取浏览器navigator对象的userAgent属性(浏览器用于HTTP请求的用户代理头的值)
|
||||
var info = navigator.userAgent;
|
||||
console.log('navigator.userAgent:',info);
|
||||
var isMobile = /iPhone|iPad|iPod|Android|mobile/i.test(info) || window.screen.width < 768 || window.screen.height < 768;
|
||||
console.log('navigator.userAgent:',info,'isMobile:',isMobile);
|
||||
//通过正则表达式的test方法判断是否包含“Mobile”字符串
|
||||
//如果包含“Mobile”(是手机设备)则返回true
|
||||
return /mobile/i.test(info);
|
||||
return isMobile;
|
||||
}
|
||||
const IS_MOBILE = isPhone();
|
||||
console.log('IS_MOBILE:',IS_MOBILE);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user