移动端js判断是app还是微信还是浏览器
const ua = navigator.userAgent.toLowerCase();
const isWeixin = ua.indexOf('micromessenger') !== -1;
const isInApp = /(^|;\s)app\//.test(ua);
if (isWeixin) {
if (window.__wxjs_environment === 'miniprogram') {
return 'wxapp';
} else {
return 'wxh5';
}
} else {
if (!isInApp) {
return 'browser';
} else {
return 'app';
}
}