小程序获取导航栏navBarHeight和底部tabbarHeight的高度(适配所有机型)

file

先说三遍:垃圾小程序垃圾小程序垃圾小程序~ 系统api中systemInfo什么都给了,就是不直接给你这两个高度,可能是涉及组件的实现吧,搭建在安卓和ios上的hybird渲染就是麻烦。

直接上答案:navBarHeight = systemInfo.statusBarHeight + 44; 有人会问44哪里来的,44就是所有ios导航栏的高度 tabbarHeight=systemInfo.screenHeight-systemInfo.safeArea.bottom + 50

height: calc(100vh - 96rpx(自定义的tabbar组件高度) - env(safe-area-inset-bottom)(适配苹果));

小程序获取导航栏navBarHeight和底部tabbarHeight的高度(适配所有机型)

https://jinzhao.me/2022/08/27/2022/2022-08-27-小程序获取导航栏navbarheight和底部tabbarheight的高度(适配所有/

作者

Carry

发布于

2022-08-27

更新于

2026-05-23

许可协议

You need to set install_url to use ShareThis. Please set it in _config.yml.
You forgot to set the business or currency_code for Paypal. Please set it in _config.yml.

评论

You forgot to set the shortname for Disqus. Please set it in _config.yml.
You need to set client_id and slot_id to show this AD unit. Please set it in _config.yml.