同问 楼主解决了吗
getMenuButtonBoundingClientRect 模拟器脱离开发者工具会报错VM52 WAService.js:2 Error: getMenuButtonBoundingClientRect:fail No window with id: 24. at Object.i (VM52 WAService.js:2) at Object.C.l.forEach.t.<computed> [as getMenuButtonBoundingClientRect] (VM52 WAService.js:2) at Object.<anonymous> (VM52 WAService.js:2) at Object.<anonymous> (VM52 WAService.js:2) at Object.<anonymous> (VM52 WAService.js:2) at :18977/appservice/< at wx.getMenuButtonBoundingClientRect> at Object.<anonymous> (VM52 WAService.js:2) at Object.value [as getMenuButtonBoundingClientRect] (apihook.js?t=wechat&s=1619254445921&v=c4a51e35d43a45c589be753667fe6667:1) at e.onLaunch (app.js? [sm]:19) at e.<anonymous> (VM52 WAService.js:2) //app.js App({ onLaunch: function () { if (!wx.cloud) { console.error('请使用 2.2.3 或以上的基础库以使用云能力') } else { wx.cloud.init({ // env 参数说明: // env 参数决定接下来小程序发起的云开发调用(wx.cloud.xxx)会默认请求到哪个云环境的资源 // 此处请填入环境 ID, 环境 ID 可打开云控制台查看 // 如不填则使用默认环境(第一个创建的环境) // env: 'my-env-id', traceUser: true, }) } // const { bottom } = wx.getMenuButtonBoundingClientRect() console.log(wx.getMenuButtonBoundingClientRect()) this.globalData = { safeTop: 0 } } }) 模拟器脱离的时候: [图片] 正常的 [图片]
2022-01-07