判断ios或者android
<script type="text/javascript"> $(function () { // android和iso下载链接 var u = navigator.userAgent; var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端 $('.dow').on('click',function () { if (isAndroid) { location.href = 'http://www.bxd365.com/app/download'; }else{ location.href = 'https://itunes.apple.com/us/app/bao-xian-wen-wen/id1076204248?l=zh&ls=1&mt=8'; } }); }); </script>
vue 封装一下,哪里需要就直接调用
// 判断android、ios终端 export function native() { let u = navigator.userAgent; let is_android = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; let is_ios = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); if (is_android) { //Android终端 return "android"; } else if (is_ios) { //IOS终端 return "ios"; } }