window.getLastWindow(getContext())
.then((windowStage:window.Window)=>{
windowStage.setWindowLayoutFullScreen(true)
//获取规避区域高度
const area=windowStage.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM)
const h = area.topRect.height
//获取到了当前设备窗口的安全区域的高度
const hp=px2vp(h)
//存入全局状态变量中,在页面通过@StorageProp获取规避区域高度。
AppStorage.setOrCreate('avoidHeight',hp)
})
获取到规避区域高度后,在最大的块级元素中利用padding({top:avoidHeight})就不会与系统任务栏重叠。