注册 X
提交 注:点击提交后系统会发送邮件到邮箱验证!(仅支持中国大陆邮箱)
我已阅读并同意 服务条款
首页 > IT技术笔记 > 查看笔记

vant-SwipeCell 滑动单元格

介绍

可以左右滑动来展示操作按钮的单元格组件。

引入

        
        
      

代码演示

基础用法

`SwipeCell` 组件提供了 `left` 和 `right` 两个插槽,用于定义两侧滑动区域的内容。

        
        
      

自定义内容

`SwipeCell` 可以嵌套任意内容,比如嵌套一个商品卡片。

        
        
      

异步关闭

通过传入 `before-close` 回调函数,可以自定义两侧滑动内容关闭时的行为。

        
        
      

        
        
      

API

Props

参数说明类型默认值
name标识符,可以在事件参数中获取到number / string-
left-width指定左侧滑动区域宽度,单位为pxnumber / stringauto
right-width指定右侧滑动区域宽度,单位为pxnumber / stringauto
before-close关闭前的回调函数Function-
disabled是否禁用滑动booleanfalse
stop-propagation是否阻止滑动事件冒泡booleanfalse

Slots

名称说明
default自定义显示内容
left左侧滑动内容
right右侧滑动内容

Events

事件名说明回调参数
click点击时触发关闭时的点击位置 (left right cell outside)
open打开时触发{ position: 'left' / 'right' , name: string }
close关闭时触发{ position: string , name: string }

beforeClose 参数

beforeClose 的第一个参数为对象,对象中包含以下属性:

参数名说明类型
name标识符string
position关闭时的点击位置 (left right cell outside)string
instanceSwipeCell 实例,用于调用实例方法SwipeCell

方法

通过 ref 可以获取到 SwipeCell 实例并调用实例方法,详见

组件实例方法

方法名说明参数返回值
open打开单元格侧边栏position: left \/ right-
close收起单元格侧边栏--

样式变量

组件提供了下列 Less 变量,可用于自定义样式,使用方法请参考

主题定制

名称默认值描述
@switch-cell-padding-top@cell-vertical-padding - 1px-
@switch-cell-padding-bottom@cell-vertical-padding - 1px-
@switch-cell-large-padding-top@cell-large-vertical-padding - 1px-
@switch-cell-large-padding-bottom@cell-large-vertical-padding - 1px-

常见问题

在桌面端无法操作组件?

参见

桌面端适配


效果图:


 打赏        分享



评论

邮箱: 昵称: