求解 在有tabBar的情况下怎么获取手机真实可用高度?

发布于 7 年前作者 oxia7118 次浏览最后编辑 7 年前来自 ask

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

6 回复
lihao
lihao1 楼6 年前

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

yduan
yduan2 楼6 年前

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

lihou
lihou3 楼6 年前

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 })

        })  

}

jie84
jie844 楼6 年前
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.

yong04
yong045 楼6 年前

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

fyuan
fyuan6 楼5 年前

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