2021-02-09js判断手机是安卓还是ios
作者:
流泪手心_521 | 来源:发表于
2021-02-09 10:17 被阅读0次/**
* @name 判断iOS
*/
export const isiOS = ()=>{
let u = navigator.userAgent;
let iOs = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端\
return iOs;
}
/**
* @name 判断android
*/
export const isAndroid = ()=>{
let u = navigator.userAgent;
let android = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
return android
}
简写:
appDown() {
var u = navigator.userAgent;
var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
if(isiOS){
window.location.href = 'ios下载地址'
}else if(isAndroid){
window.location.href = '安卓下载地址'
}
}
本文标题:2021-02-09js判断手机是安卓还是ios
本文链接:https://www.haomeiwen.com/subject/lhiqxltx.html
网友评论