谁能打救这个神奇的bug

发布于 7 年前作者 xiulanyu8261 次浏览最后编辑 7 年前来自 ask
  • 当前 Bug 的表现(可附上截图)
try {
        let { top, height } = wx.getMenuButtonBoundingClientRect();
        if (!top) top = 20;
        if (!height) height = 48;
        this.setData({
          top: top + height + 8
        })
    } catch (e) {}
  • 预期表现

正常 ,至少try catch下要保证不报错吧?

  • 复现路径

  • 提供一个最简复现 Demo

1 回复
naxie
naxie1 楼5 年前

基础库版本太低了?基础库 2.1.0 开始支持,低版本需做兼容处理https://developers.weixin.qq.com/miniprogram/dev/api/wx.getMenuButtonBoundingClientRect.html