右上角胶囊按钮的布局位置信息部分手机获取错误
发布于 6 年前 作者 na09 4952 次浏览 来自 问答

这是一个胶囊位置信息的console,top位置信息在有些手机上获取错误,少了状态栏高度,我现在手动判断这个top位置高度,自己把状态栏高度加上去貌似正常了,但这样始终觉得不靠谱,或许是我代码逻辑错了,还是个bug问题,希望官方同学给个回复。谢谢。

附上我的逻辑代码:

// 获取系统状态栏信息

wx.getSystemInfo({

success: e => {

this.globalData.StatusBar = e.statusBarHeight;

let custom = wx.getMenuButtonBoundingClientRect();

this.globalData.Custom = custom;

if (custom.top < 18) {

custom.top = custom.top + e.statusBarHeight

custom.bottom = custom.bottom + e.statusBarHeight

}

this.globalData.CustomBar = custom.bottom + custom.top - e.statusBarHeight;

console.log(‘StatusBar:’ + e.statusBarHeight)

console.log(custom)

console.log(‘CustomBar:’ + this.globalData.CustomBar)

}

})

请同学们尽快回复,新版本更新,这个bug问题都炸锅了。

2 回复

麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

这个是我加上状态栏高度的console

回到顶部