//判断移动端设备
isWechat: () => {
let ua = window.navigator.userAgent.toLowerCase()
let isWechat = ua.match(/MicroMessenger/i) == ‘micromessenger‘ //微信端
return isWechat && location.href.indexOf(‘192.‘) == -1;
},
isAndroid: (...objs) => {
let u = navigator.userAgent;
let isAndroid = u.indexOf(‘Android‘) > -1 || u.indexOf(‘Adr‘) > -1; //android终端
return isAndroid;
},
isIos: (...objs) => {
let u = navigator.userAgent;
let isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
return isiOS;
},
原文:https://www.cnblogs.com/huangjiaqi/p/14794955.html