当前位置:网站首页>vant tabbar遮挡内容的解决方式
vant tabbar遮挡内容的解决方式
2022-07-05 15:21:00 【Joy_917】
前面我们提到,使用vant-tabbar 来替换原生的tabbar,但是实际使用中发现,当tab页内容过多之后,tabbar会遮挡页面最下方的内容
直接上图:
我们会发现,两个按钮消失了,从 2 处可以看到,屏幕右侧的 scroll 越过了 tabbar 一栏,说明内容是被遮挡住了,确实滑到了底部但是看不到按钮。
为什么会这样呢?小程序的自定义组件,是通过 slot 的方式将内容注入进去再渲染出来的,而 vant-tabbar 组件是 通过 cover-view 的形式 覆盖在原生组件之上的视图 ,它并不是通常意义上的引用组件,所以和内容元素并不是同级关系。
开始我想既然被 tabbar cover 住了一块区域,那我找到 tabbar 组件的高度,然后把底部元素顶上去不就好了吗?
如上图,确实找到了,vant默认是50px,不过固定效果堪忧,大家感兴趣的可以试一下。我猜测是由于组件底部还有一段安全距离,所以这个 height 并不完全等于 tabbar 的占用高度,其次也会受机型影响。
期间也试了另一种方式,用 scroll-view 标签包裹住内容,然后设定一个固定高度,比如 500px,这样滑动内容不受 tabbar 影响,因为区域不相交。但是同样的也受机型影响。
所以最终还是选用百分比的形式顶上去一段距离,也就是:
<view style="padding-bottom: 25%;"></view>
看下实际效果:
测了大部分机型还算ok。缺点就是每一个有 tabbar 的页面,都需要加一个空 view,不太优雅。所以我考虑能否直接修改自定义组件,在 slot 前后直接加上空 view,或者直接设置 slot 的样式控制内部元素,不过都没效果,所以作罢。
只能尽量使用跳转新页面并隐藏 tabbar 来避免这种情况。后面如果发现更好的方式,会同步更新,也欢迎大佬告知,感谢~
完整代码放到了github上,持续更新中,欢迎 star 支持:https://github.com/Joy917/signgo
边栏推荐
- Common MySQL interview questions (1) (written MySQL interview questions)
- Lesson 4 knowledge summary
- Interval DP (gravel consolidation)
- How difficult is it to pass the certification of Intel Evo 3.0? Yilian technology tells you
- Severlet learning foundation
- Appium automation test foundation - appium basic operation API (I)
- 16.[STM32]从原理开始带你了解DS18B20温度传感器-四位数码管显示温度
- Data communication foundation OSPF Foundation
- [brief notes] solve the problem of IDE golang code red and error reporting
- Arduino controls a tiny hexapod 3D printing robot
猜你喜欢

Summary of the third class

Usage and usage instructions of JDBC connection pool

【 note 】 résoudre l'erreur de code IDE golang
![17.[STM32]仅用三根线带你驱动LCD1602液晶](/img/c6/b56c54da2553a451b526179f8b5867.png)
17.[STM32]仅用三根线带你驱动LCD1602液晶

Clock switching with multiple relationship

How difficult is it to pass the certification of Intel Evo 3.0? Yilian technology tells you

CSRF, XSS science popularization and defense

Codasip为RISC-V处理器系列增加Veridify安全启动功能

力扣今日题-729. 我的日程安排表 I
![21.[STM32]I2C协议弄不懂,深挖时序图带你编写底层驱动](/img/f4/2c935dd9933f5cd4324c29c41ab221.png)
21.[STM32]I2C协议弄不懂,深挖时序图带你编写底层驱动
随机推荐
Quick completion guide for manipulator (IX): forward kinematics analysis
String modification problem solving Report
Noi / 1.5 37: mercenaries
Array sorting num ranking merge in ascending order
I'm fat, huh
MySQL表字段调整
Fundamentals of data communication - Principles of IP routing
20.[STM32]利用超声波模块和舵机实现智能垃圾桶功能
定义严苛标准,英特尔Evo 3.0正在加速PC产业升级
RepLKNet:不是大卷积不好,而是卷积不够大,31x31卷积了解一下 | CVPR 2022
Appium自动化测试基础 — APPium基础操作API(二)
Appium自动化测试基础 — APPium基础操作API(一)
vlunhub- BoredHackerBlog Moriarty Corp
Reasons and solutions for redis cache penetration and cache avalanche
Common interview questions about swoole
Bugku's Ping
Surpass palm! Peking University Master proposed diverse to comprehensively refresh the NLP reasoning ranking
如何将 DevSecOps 引入企业?
Detailed explanation of C language branch statements
Virtual base class (a little difficult)