SwipeCell 滑动单元格
uni-appH5微信小程序App
跨端列表滑动操作容器,支持右侧操作插槽和程序化开关。
何时使用
列表项需要隐藏的快捷操作(删除、置顶、标记已读)时。
何时不使用
操作需要始终可见时用普通按钮;操作超过 3 个时用 ActionSheet。
本文档为 uni-app 端组件契约;Web 端同名组件 API 可能略有差异,请以对应包文档为准。下方手机预览实时运行 uni-app H5 演示。
Props
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
disabled | boolean | false | 禁用滑动 |
threshold | number | 30 | 松手后判定「展开」所需滑动的距离(px),超过则吸附展开,否则弹回 |
actionWidth | number | 120 | 右侧操作区宽度,单位 px |
Events
| 名称 | 载荷 | 说明 |
|---|---|---|
open | void | 操作区完全展开时触发 |
close | void | 操作区收起(弹回 / 点击内容收起 / 程序化 close)时触发 |
Slots
| 名称 | 说明 |
|---|---|
default | 单元格内容 |
right | 右侧操作区 |
Methods
| 名称 | 签名 | 说明 |
|---|---|---|
open | - | - |
close | - | - |
示例
左滑操作
vue
<SwipeCell>
<Cell title="消息通知" value="左滑试试" />
<template #right><view class="row">
<Button variant="secondary" size="sm">置顶</Button>
<Button variant="danger" size="sm">删除</Button>
</view></template>
</SwipeCell>列表组合
vue
<Stack :gap="10">
<SwipeCell>
<Cell title="会话 A" value="左滑操作" />
<template #right><Button variant="danger" size="sm">删除</Button></template>
</SwipeCell>
<SwipeCell>
<Cell title="会话 B" value="左滑操作" />
<template #right><Button variant="secondary" size="sm">已读</Button></template>
</SwipeCell>
</Stack>自定义阈值
vue
<SwipeCell :threshold="40" :action-width="140">
<Cell title="自定义手感" value="更大触发阈值" />
<template #right><Button variant="danger" size="sm">删除</Button></template>
</SwipeCell>