当前位置:网站首页>vant popup+其他组件的组合使用,及避坑指南
vant popup+其他组件的组合使用,及避坑指南
2022-07-05 15:21:00 【Joy_917】
做小程序开发,相信大家对于表单收集肯定不陌生。但是我们经常会碰到一些比较稍微复杂的选项,并不是简单的填一些文字,数字,或者选择一下是否就能搞定的。可能需要交互判断,或者结合其他自定义组件才能很好的展示出来,但这种组件往往都很占空间,如果一股脑都叠罗汉似的放到表单里,页面会显得非常拥挤。
那么如何解决这个问题呢?常见的方式有,popup弹出层、跳转新页面等等。
其中跳转页面的加载卡顿和不连续感会影响用户体验,除非是单独的多项收集页面,信息量很大那另说。
所以在实际应用中,popup弹出层是最常见的,用来解决组件占用屏幕问题的方式。先来看下演示:
这是一个典型的 popup + treeSelect 组件的组合,当然了,这里的treeSelect可以换成 timePicker 或者其他组件。当你觉得开新页面是大炮打蚊子,不开又很挤的时候就可以用这种方式,流畅又省空间。
用法也很简单,标签嵌套就可以了:
<van-popup show="{
{ showTree }}" round position="bottom" custom-style="height: 50%" bind:close="onCloseTreeSelect">
<van-tree-select items="{
{ items }}" main-active-index="{
{ mainActiveIndex }}" active-id="{
{ activeId }}" bind:click-nav="onClickNav" bind:click-item="onClickItem" />
</van-popup>
注意: 这里有个很坑的点是,vant 官方文档默认的 popup 属性 close-on-click-overlay——是否在点击遮罩层后关闭,默认是 true,但是如果你不实现 bind:close 方法的话,点击遮罩层是不会关闭弹出层的
另外,对于本身就有取消或者确认的组件,如果和 popup 组合时,建议覆盖 popup 的 close 按钮,否则会比较乱。
完整代码放到了github上,持续更新中,欢迎支持:https://github.com/Joy917/signgo
边栏推荐
- JS knowledge points-01
- Bugku's eyes are not real
- The difference between SQL Server char nchar varchar and nvarchar
- 1330: [example 8.3] minimum steps
- lvgl 显示图片示例
- 如何将 DevSecOps 引入企业?
- Bugku easy_ nbt
- I spring web upload
- Go language programming specification combing summary
- SQL injection sqllabs (basic challenges) 1-10
猜你喜欢
19.[STM32]HC_SR04超声波测距_定时器方式(OLED显示)
RepLKNet:不是大卷积不好,而是卷积不够大,31x31卷积了解一下 | CVPR 2022
Good article inventory
Ionic Cordova project modification plug-in
Data communication foundation - dynamic routing protocol rip
No one consults when doing research and does not communicate with students. UNC assistant professor has a two-year history of teaching struggle
Bugku telnet
Common redis data types and application scenarios
First PR notes
18.[STM32]读取DS18B20温度传感器的ROM并实现多点测量温度
随机推荐
Can gbase 8A view the location of SQL statement history?
修改pyunit_time使得其支持‘xx~xx月’的时间文本
keep-alive
Example of lvgl display picture
DataArts Studio数据架构——数据标准介绍
示例项目:简单的六足步行者
MySQL table field adjustment
MySQL overview
【 note 】 résoudre l'erreur de code IDE golang
Arduino控制微小的六足3D打印机器人
lv_font_conv离线转换
Information collection of penetration test
Redis' transaction mechanism
Basic JSON operations of MySQL 5.7
CSRF, XSS science popularization and defense
Stop B makes short videos, learns Tiktok to die, learns YouTube to live?
Appium自动化测试基础 — APPium基础操作API(一)
Noi / 1.5 06: element maximum span value of integer sequence
SQL Server learning notes
20. [stm32] realize the function of intelligent garbage can by using ultrasonic module and steering gear