# 6.2 滑动列表(Swipe List)

可侧滑的列表组件

# 基础用法

<template>
  <dof-swipe-list :data="listData" @onNodeClick="onNodeClick">
    <template slot-scope="{ val }">
      <text>{{ val.item.title }}</text>
    </template>
  </dof-swipe-list>
</template>

<script>
export default {
  data() {
    return {
      listData: [
        {
          title: '列表项',
          autoClose: true,
          right: [
            {
              text: '删除',
              style: { backgroundColor: '#F56428' },
              onPress: () => {}
            }
          ]
        }
      ]
    }
  },
  methods: {
    onNodeClick(item, index) {}
  }
}
</script>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32

# Attributes

Prop Type Required Default Description
container-style Object N {"backgroundColor":"#dddddd","borderTopColor":"#dddddd","borderTopWidth":1} 列表外层容器样式
data Array N [] 列表数据,见注 1
height Number N 90 列表项高度
styles Object N undefined 每个主内容区域的样式
need-dark-mode Boolean N false 是否启用 M-dark/T-dark 内置暗黑适配
background-color String N '' 背景色
border-color String N '' 边框 / 分隔线颜色
action-background-color String N '' 操作区域背景色
action-text-color String N '' 操作文字颜色
isRTL Boolean N false 是否启用 RTL(从右到左)布局;默认关闭 ^2.5.10

RTL 下操作按钮显示在左侧,右滑展开、左滑收起;仍使用 right 配置操作项,配置数组和回调数据无需反转。

设置 :need-dark-mode="true" 可启用内置暗黑配色,主题初始化与构建配置见 接入说明。

颜色属性为空时使用内置配色;业务显式颜色和样式覆盖优先于默认配色,关闭暗黑适配后仍有效。

containerStyle、styles 和 child.style 中的业务样式优先。

  • 注 1:每个 data 项必须提供 right 数组;组件会以其长度计算可侧滑区域宽度。right 的每项配置如下:
字段 Type Required Description
right Array Y 右侧操作数组
right[].text String Y 操作按钮文本
right[].style Object N 操作按钮和文本样式
right[].onPress Function Y 操作按钮点击回调
autoClose Boolean N 点击右侧操作后是否自动收起,默认不收起

# Slots

插槽名 作用域参数 说明
默认插槽 val.item、val.index 自定义每条列表项的主内容

# Events

事件名 说明 回调参数
onNodeClick 点击未展开的列表主内容 item、index