求解 在有tabBar的情况下怎么获取手机真实可用高度?
发布于 6 年前 作者 oxia 6950 次浏览 来自 问答

wx.getSystemInfo和wx.createSelectorQuery()在有tabBar的情况下获取的可用高度都有误。

6 回复

年前就提出了这个BUG,到现在一点回应都没有。

一直都没有人管这个BUG啊?。。。。。。。。。。。。。。。

onReady中获取,不要在onLoad中获取,可以在view中声明元素<view style=‘height:100%;width:100%;position:fixed;z-index:-100;’ id=‘getHeight’></view>

onReady:function(){

    var query = wx.createSelectorQuery();

        query.select(’#getHeight’).boundingClientRect()

        query.exec(function (resu) {      

          var res = wx.getSystemInfoSync();

          var height = resu[0].height;                                   //这个便是页面的可用高度

          var _height = ‘’;

          var width = resu[0].width;

          if (res.system.indexOf(“iOS”) > -1) {

            _height = height - 120;

          } else {

            _height = height - 70;

          }

          self.setData({ “windowHight”: _height + “px”, height: _height })

        })  

}

function getSystemInfo(that, data) {
  var query = wx.createSelectorQuery()
  query.select('.head').boundingClientRect()
  query.exec(function (res) {
    windowHeight = Math.round(res[0].height)
    console.log(windowHeight);
    let a = data_processing(data)
    //为了上下都有能滑动,所以扔进去三个时间
    display_data.push(mydate[0])
    display_data.push(mydate[0])
    display_data.push(mydate[0])
    that.setData({
      data: a,
      display_data: display_data
    })
    console.log('display_data', display_data)
    console.log('mydate', mydate)
 
  })
}

实际高度46.25,代码返回51.

官方人员呢?BUG都不管了吗?

麻烦官方人员出来改一下这个BUG好不好?已经提出来这么久了。

回到顶部