一个页面 , 顶部 我自定义 navbar , 中间 view , 除去 底部 tabbar 高度 , 填满剩余 空间 , 请问 这个 中间 view 高度 怎么计算 得到 ?
中间view height = 100vh - uni.getSystemInfoSync().safeArea.top - 胶囊按钮 (uni.getMenuButtonBoundingClientRect().height ) - 55px tabbar 高度 吗 ?
这个计算方法 是否 正确 ? 或者 是否有 更优解 ? tabbar 是否有 uni.gettabbar().height 类似这个接口 ?
2 个回复
DCloud_UNI_yuhe
tabbar 的高度是 50px ,可以看一下文档:https://uniapp.dcloud.net.cn/collocation/pages.html#pages-json-%E9%A1%B5%E9%9D%A2%E8%B7%AF%E7%94%B1
1***@qq.com (作者)
主要 是 这个 问题 : 计算 中间 view , 填满剩余空间 的 计算 方式 ?
一个页面 , 顶部 我自定义 navbar , 中间 view , 除去 底部 tabbar 高度 , 填满剩余 空间 , 请问 这个 中间 view 高度 怎么计算 得到 ?
中间 view height = 100vh - uni.getSystemInfoSync().safeArea.top - 胶囊按钮 (uni.getMenuButtonBoundingClientRect().height ) - 50px tabbar 高度 ?
恭喜n发财
没有特定的公式,都是孰能生巧,可以问问ai,然后多调试。你当前的式子应该还少了个 safeArea.bottom,底部安全距离
2025-05-15 14:06