Determine whether it is Android or iOS
Only consider the two cases of Android and ios
// 判断是安卓还是 ios
function checkDeviceType() {
const u = navigator.userAgent;
const isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
if (isiOS) {
terminalType.system = "ios";
} else {
terminalType.system = "andriod";
}
}
Determine whether to open in WeChat
// 判断是否在微信中打开
function isWeChat() {
const userAgent = navigator.userAgent.toLowerCase();
return /MicroMessenger/i.test(userAgent)
}
Additional words
In the warehouse , it also provides a summary of many common front-end requirements and implementations. Guests are welcome to take a look~
If this note can help you, please help to highlight it on githubstar
, thank you!