-
Creator 版本: 2.4.2
-
目标平台: 构建平台:微信小游戏
-
重现方式:在QQ小程序开发者工具中,预览添加了SafeArea的场景
-
首个报错:
adapter-min.js? [sm]:1 Uncaught TypeError: Cannot read property ‘top’ of undefined
at Object.window.__globalAdapter.u.getSafeArea (adapter-min.js? [sm]:1)
at Object.e.getSafeAreaRect (adapter-min.js? [sm]:1)
at r.updateArea (cocos2d-js-min.js:1)
at r.onEnable (cocos2d-js-min.js:1)
at r.invokeOnEnable [as _invoke] (cocos2d-js-min.js:1)
at r.invoke (cocos2d-js-min.js:1)
at r.activateNode (cocos2d-js-min.js:1)
at r._activate (cocos2d-js-min.js:1)
at 27.cc.Director.runSceneImmediate (cocos2d-js-min.js:1)
at cocos2d-js-min.js:1 -
重现概率:
官方帮忙适配一下吧,没有效果不报错也行
感谢解答!
在进入场景后马上执行
cc.sys.getSafeAreaRect = function () {
let _visibleRect = cc.view.getVisibleSize();
_visibleRect.height -= 132; (132是正常值 可根据自行修改)
return cc.rect(0, 0, _visibleRect.width, _visibleRect.height);
};