微信小程序判断是否为 iphoneX,iphoneXR等

  onLaunch: function () {
    let _self = this;
    wx.getSystemInfo({
      success: res => {
        let modelmes = res.model;
        if (modelmes.search('iPhone X') != -1 || modelmes.search('iPhone 11') != -1 || modelmes.search('iPhone 11 Pro Max') != -1) {
          _self.globalData.isIphoneX = true
        }
        wx.setStorageSync('modelmes', modelmes)
      }
    })
}
globalData: {
    isIphoneX: false,
}

页面:
data:{
     isIphoneX: false,
}
onLoad: function (options) {
    let isIphoneX = app.globalData.isIphoneX;
    
}

this.setData({
      isIphoneX: isIphoneX,
})

//获取元素宽高

  getHeaderHeight() {
    //创建节点选择器
    var query = wx.createSelectorQuery();
    //选择id
    var that = this;
    query.select('.hearderNav').boundingClientRect(function (rect) {
      console.log('1111-->', rect.height)
      that.setData({
        navHeight: rect.height
      })
    }).exec();
  },

 

你可能感兴趣的:(微信小程序)