# 列表侧滑删除
常用于列表中,通过向左侧滑手势触发,展开原本隐藏的更多功能,多用于删除、收藏等功能。
# 示例
<template>
<div class="wrapper">
<dof-minibar title="6.1列表侧滑删除"></dof-minibar>
<scroller style="padding-bottom: 60px;">
<div class="title-box">
<text class="title-text">宽列表</text>
</div>
<dof-swipe-action
class="m-t-16"
@dofCellClicked="cellClicked"
@dofRightClicked="rightClicked"
:list-data="cellData1"
>
</dof-swipe-action>
<dof-swipe-action
class="m-t-16"
@dofCellClicked="cellClicked"
@dofRightClicked="rightClicked"
:list-data="cellData2"
>
</dof-swipe-action>
<dof-swipe-action
class="m-t-16"
@dofCellClicked="cellClicked"
@dofRightClicked="rightClicked"
:list-data="cellData3"
>
</dof-swipe-action>
<div class="title-box m-t-16">
<text class="title-text">窄列表</text>
</div>
<dof-swipe-action
class="m-t-16"
@dofCellClicked="cellClicked"
@dofRightClicked="rightClicked"
:list-data="cellData4"
>
</dof-swipe-action>
<dof-swipe-action
class="m-t-16"
@dofCellClicked="cellClicked"
@dofRightClicked="rightClicked"
:list-data="cellData5"
>
</dof-swipe-action>
<dof-swipe-action
class="m-t-16"
@dofCellClicked="cellClicked"
@dofRightClicked="rightClicked"
:list-data="cellData6"
>
</dof-swipe-action>
<div class="title-box m-t-16">
<text class="title-text">卡片式(主推)</text>
</div>
<dof-swipe-action
class="m-t-16"
@dofCellClicked="cellClicked"
@dofRightClicked="rightClicked"
@switchChange="switchChange"
:padding="32"
:list-data="cellData7"
>
</dof-swipe-action>
</scroller>
</div>
</template>
<style scoped>
.wrapper {
background-color: #f9f9f9;
}
.m-t-16 {
margin-top: 16px;
}
.title-box {
padding: 32px;
background-color: #e5e5e8;
}
.title-text {
font-family: PingFangSC-Medium;
font-size: 36px;
color: #000000;
font-weight: 500;
}
@media screen and (weex-theme: colmo) {
.wrapper {
background-color: #151617;
}
}
</style>
<script>
import { DofMinibar, DofSwipeAction } from 'dolphin-weex-ui'
export default {
components: { DofMinibar, DofSwipeAction },
data: () => ({
cellData1: [
{
title: '热水器',
rightText: '小蓝的家',
desc: '浴室',
rightItem: [{ text: '删除', bgColor: '#B35336', width: 116 }]
}
],
cellData2: [
{
title: '热水器',
rightText: '小蓝的家',
desc: '浴室',
rightItem: [
{ text: '收藏', bgColor: '#27835B', width: 116 },
{ text: '删除', bgColor: '#B35336', width: 116 }
]
}
],
cellData3: [
{
title: '热水器',
rightText: '小蓝的家',
desc: '浴室',
rightItem: [
{ text: '置顶', bgColor: '#2962BC', width: 116 },
{ text: '收藏', bgColor: '#27835B', width: 116 },
{ text: '删除', bgColor: '#B35336', width: 116 }
]
}
],
cellData4: [
{
title: '热水器',
rightText: '小蓝的家',
rightItem: [{ text: '删除', bgColor: '#B35336', width: 116 }]
}
],
cellData5: [
{
title: '热水器',
rightText: '小蓝的家',
rightItem: [
{ text: '收藏', bgColor: '#27835B', width: 116 },
{ text: '删除', bgColor: '#B35336', width: 116 }
]
}
],
cellData6: [
{
title: '热水器',
rightText: '小蓝的家',
rightItem: [
{ text: '置顶', bgColor: '#2962BC', width: 116 },
{ text: '收藏', bgColor: '#27835B', width: 116 },
{ text: '删除', bgColor: '#B35336', width: 116 }
]
}
],
cellData7: [
{
title: '列表标题',
desc: '副标题',
switchVal: true,
hasArrow: false,
avatarIconFont: '\u4793',
rightItem: [{ text: '删除', bgColor: '#B35336', width: 116 }]
}
]
}),
computed: {},
created() {},
methods: {
cellClicked(e) {
this.$toast(`example cell clicked, ${e.index}`)
},
rightClicked(params) {
//params属性包括当前列表索引以及侧滑后按钮的索引和text文本
this.$toast(`rightClicked,${JSON.stringify(params)}`)
},
switchChange(item) {
this.$toast(item)
}
}
}
</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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# Attributes
Prop | Type | Required | Default | Description |
---|---|---|---|---|
list-data | Array | Y | - | 列表数据 |
list-data['rightItem'] | Array | Y | - | 列表滑动后右侧的内容 见注1 |
- 注1:
Prop | Type | Required | Default | Description |
---|---|---|---|---|
text | String | Y | - | 滑动显示的文本 |
bgColor | String | Y | - | 滑动显示的背景色 |
# Events
事件名 | 说明 | 回调参数 |
---|---|---|
dofCellClicked | 单击列表 | e ,e.index 当前列表索引 |
dofRightClicked | 单击滑动列表后右侧的选项 | e ,e.index ,e.i ,e.text 当前列表索引,当前点击的侧滑选项索引,当前点击的侧滑选项文本 |
点我扫二维码 查看demo