啥都不多说了,直接撸代码吧。
//检测相关的设备型号 var mobileUAKeywords = ["nokia", "sony", "ericsson", "mot", "samsung", "htc", "sgh", "lg", "sharp", "sie-", "philips", "panasonic", "alcatel", "lenovo", "iphone", "ipod", "blackberry", "meizu", "android", "netfront", "symbian", "ucweb", "windowsce", "palm", "operamini", "operamobi", "opera mobi", "openwave", "nexusone", "cldc", "midp", "wap", "mobile" ]; var userAgent = navigator.userAgent; var regExp = new RegExp(mobileUAKeywords.join("|"), "i"); var browser = { mobile: !!userAgent.match(regExp), android: /android/i.test(userAgent) || /linux/i.test(userAgent), iPad: /iPad/i.test(userAgent), iphone: /iphone/i.test(userAgent), ipod: /ipod/i.test(userAgent), isWechatBrowser: /micromessenger/i.test(userAgent) }; //初始化型号设备为false,不显示按钮 $scope.android = false; $scope.ios = false; $scope.wx = false; /*$scope.ios = browser.iphone*/ if (browser.android) { $scope.android = true; } else if(browser.iphone || browser.ipod || browser.iPad){ $scope.ios = true; } //判断是否是微信 if (browser.isWechatBrowser) { $scope.wx = true; }