问题在于三星平板电脑。
我想展示一些东西,如果设备是手机,但不是平板电脑。
设备检测器显示:
- isMobile():true
- isTablet():false
这是来自模块的完整数据:
{"raw":{"userAgent":"Mozilla/5.0 (Linux; Android 4.4.2; es-us; SAMSUNG SM-T230NU Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/1.5 Chrome/28.0.1500.94 Safari/537.36","os":{"windows":false,"mac":false,"ios":false,"android":true,"linux":true,"unix":false,"firefox-os":false,"chrome-os":false,"windows-phone":false,"ps4":false,"vita":false,"unknown":false},"browser":{"chrome":true,"firefox":false,"safari":true,"opera":false,"ie":false,"ms-edge":false,"ps4":false,"vita":false,"unknown":false},"device":{"android":true,"ipad":false,"iphone":false,"ipod":false,"blackberry":false,"firefox-os":false,"chrome-book":false,"windows-phone":false,"ps4":false,"vita":false,"unknown":false},"os_version":{"windows-3-11":false,"windows-95":false,"windows-me":false,"windows-98":false,"windows-ce":false,"windows-2000":false,"windows-xp":false,"windows-server-2003":false,"windows-vista":false,"windows-7":false,"windows-8-1":false,"windows-8":false,"windows-10":false,"windows-phone-7-5":false,"windows-phone-8-1":false,"windows-phone-10":false,"windows-nt-4-0":false,"unknown":false}},"os":"android","browser":"chrome","device":"android","os_version":"unknown","browser_version":"28.0.1500.94"}
提前致谢。
答案 0 :(得分:0)
答案 1 :(得分:0)
问题出在Android平板电脑上,ng-device-detector显示Android平板电脑和Android手机的相同信息。 寻找解决方案,我发现所有智能手机在userAgent中都有字符串“Mobile”,但平板电脑没有。
Here's所有智能手机userAgents的列表。
简单地说,我使用此功能来替换ng-device-detector“isMobile”功能:
deviceDetector.isMobile = function(){
var ua = deviceDetector.raw.userAgent;
return ua.match(/Mobile/i);
}
谢谢大家。 对不起我的英语,我说西班牙语。