zoukankan      html  css  js  c++  java
  • 页面环境判断

    项目中我们经常会使用一套H5页面内嵌到APP,小程序中。有些场景就需要根据不同的环境,来处理一些需求,这时候就需要进行环境判断了。

    const ua = window.navigator.userAgent.toLowerCase();
    const AppUtils = {
        isApp: ua.indexOf('lvmm') > -1,
        isIOS: ua.indexOf('iphone') > -1 || ua.indexOf('ipad') > -1, //ios
        isIphoneX: ua.indexOf('iphone') > -1 && (
            (screen.width === 375 && screen.height === 812) || (screen.width === 414 && screen.height === 896)
        ), //IOS-IphoneX
        isAndriod: ua.indexOf('lvmm') > -1 && ua.indexOf('android') > -1,
        isWX:ua.match(/MicroMessenger/i) == 'micromessenger',//微信环境
        isWXSP: window.__wxjs_environment === 'miniprogram' || ua.indexOf('miniprogram') > -1, //微信小程序环境
        IsBD: ua.indexOf('baidu') > -1
    }
  • 相关阅读:
    java线程(1)-线程同步
    Scala:(3)数组
    Codeforces 899F Letters Removing
    拼图游戏的可解性
    Hash
    哈夫曼编码
    莫比乌斯
    FFT
    Ropes
    区间合并
  • 原文地址:https://www.cnblogs.com/zsj-02-14/p/13523228.html
Copyright © 2011-2022 走看看