css适配
方向 | 非安全区空间距离 |
top | var(--immersive-area-inset-top, 0) |
bottom | var(--immersive-area-inset-bottom, 0) |
js适配
获取top和bottom非安全区空间距离,单位为vh
top:document.documentElement.style.getPropertyValue('--immersive-area-inset-top')
bottom: document.documentElement.style.getPropertyValue('--immersive-area-inset-bottom')
业务实践
低成本适配方案:JS获取__immersive_area_top高度,布局根容器根据该值决定是否向上移动__immersive_area_top,比如无值则不向上移动,有值则向上移动__immersive_area_top