# 10.1 轮播图(Swiper)
# dof-swiper
轮播图组件
# 实例
# 基础用法
<template>
<div class="wrapper">
<dof-minibar title="开关"> </dof-minibar>
<scroller class="scroller">
<dof-catalog title="开关基础组件" background-color="#daf9ca" :has-margin="true"></dof-catalog>
<dof-cell title="开关" :has-arrow="false">
<dof-switch
slot="switch"
class="switch"
:checked="value1"
@dof-change="handleChange({ type: 1 })"
:disabled="false"
>
</dof-switch>
</dof-cell>
<dof-cell title="开关(关闭)" :has-arrow="false">
<dof-switch
slot="switch"
class="switch"
:checked="value2"
@dof-change="handleChange({ type: 2 })"
:disabled="false"
>
</dof-switch>
</dof-cell>
<dof-cell title="开关(禁用)" :has-arrow="false">
<dof-switch slot="switch" class="switch" :checked="value4" :disabled="true"> </dof-switch>
</dof-cell>
<dof-catalog title="开关颜色可配置" background-color="#daf9ca" :has-margin="true"></dof-catalog>
<div class="a-flex">
<dof-switch
type="default"
slot="switch"
class="switch"
:checked="value1"
@dof-change="handleChange({ type: 1 })"
:disabled="false"
>
</dof-switch>
<dof-switch
type="turquoise"
slot="switch"
class="switch"
:checked="value1"
@dof-change="handleChange({ type: 1 })"
:disabled="false"
>
</dof-switch>
<dof-switch
type="purple"
slot="switch"
class="switch"
:checked="value1"
@dof-change="handleChange({ type: 1 })"
:disabled="false"
>
</dof-switch>
</div>
<div class="a-flex">
<dof-switch
type="default"
slot="switch"
class="switch"
:checked="value1"
@dof-change="handleChange({ type: 1 })"
:disabled="true"
>
</dof-switch>
<dof-switch
type="turquoise"
slot="switch"
class="switch"
:checked="value1"
@dof-change="handleChange({ type: 1 })"
:disabled="true"
>
</dof-switch>
<dof-switch
type="purple"
slot="switch"
class="switch"
:checked="value1"
@dof-change="handleChange({ type: 1 })"
:disabled="true"
>
</dof-switch>
</div>
<div class="a-flex">
<dof-switch
type="orange-red"
slot="switch"
class="switch"
:checked="value1"
@dof-change="handleChange({ type: 1 })"
:disabled="false"
>
</dof-switch>
<dof-switch
type="orange"
slot="switch"
class="switch"
:checked="value1"
@dof-change="handleChange({ type: 1 })"
:disabled="false"
>
</dof-switch>
<div class="w-96"></div>
</div>
<div class="a-flex">
<dof-switch type="orange-red" slot="switch" class="switch" :checked="value4" :disabled="true"> </dof-switch>
<dof-switch type="orange" slot="switch" class="switch" :checked="value4" :disabled="true"> </dof-switch>
<div class="w-96"></div>
</div>
<div class="a-flex">
<dof-switch
type="red"
slot="switch"
class="switch"
:checked="value1"
@dof-change="handleChange({ type: 1 })"
:disabled="false"
>
</dof-switch>
<dof-switch
type="brown"
slot="switch"
class="switch"
:checked="value1"
@dof-change="handleChange({ type: 1 })"
:disabled="false"
>
</dof-switch>
<div class="w-96"></div>
</div>
<div class="a-flex">
<dof-switch type="red" slot="switch" class="switch" :checked="value4" :disabled="true"> </dof-switch>
<dof-switch type="brown" slot="switch" class="switch" :checked="value4" :disabled="true"> </dof-switch>
<div class="w-96"></div>
</div>
<dof-catalog title="开关中配置 loading" background-color="#daf9ca" :has-margin="true"></dof-catalog>
<dof-cell title="开关" :has-arrow="false">
<dof-switch
slot="switch"
class="switch"
:checked="value3"
@dof-change="handleChange({ type: 3 })"
:disabled="false"
:loading="loadingFlag"
>
</dof-switch>
</dof-cell>
<dof-catalog title="无障碍示例" background-color="#daf9ca" :has-margin="true"></dof-catalog>
<dof-cell title="设置" :autoAccessible="false" :has-arrow="false">
<dof-switch
v-if="isIos"
slot="switch"
class="switch"
:checked="value5"
@dof-change="handleChange({ type: 5 })"
:disabled="false"
:aria-label="blindHelptext"
:accessible="true"
>
</dof-switch>
<dof-switch
v-if="!isIos"
slot="switch"
class="switch"
:checked="value5"
@dof-change="handleChange({ type: 5 })"
:disabled="false"
:blind-helptext="blindHelptext"
>
</dof-switch>
</dof-cell>
<div class="h-100"></div>
</scroller>
</div>
</template>
<script>
import { DofMinibar, DofSwitch, DofCell, DofCatalog } from 'dolphin-weex-ui'
export default {
components: { DofMinibar, DofSwitch, DofCell, DofCatalog },
data() {
return {
leftButton: 'http://dolphin-weex-dev.msmartlife.cn/cdn/images/header/icon_back_white@3x.png',
value1: true,
value2: false,
value3: true,
value4: true,
value5: true,
loadingFlag: false,
isIos: false,
loadingImg: 'http://dolphin-weex-dev.msmartlife.cn/static/component/loading/image/loading-white.png'
}
},
created() {
this.isIos = weex.config.env.platform == 'iOS'
},
computed: {
blindHelptext() {
return this.value5 ? '关闭。按钮' : '开启。按钮。'
}
},
methods: {
handleChange({ type }) {
let self = this
if (type === 1) {
this.value1 = !this.value1
} else if (type === 2) {
this.value2 = !this.value2
} else if (type === 3) {
this.loadingFlag = true
setTimeout(() => {
self.loadingFlag = false
self.value3 = !self.value3
}, 500)
} else if (type == 5) {
this.value5 = !this.value5
}
},
minibarRightButtonClick() {
this.$reload()
}
}
}
</script>
<style scoped>
.wrapper {
background-color: #ffffff;
}
.scroller {
width: 750px;
}
.switch-wrapper {
margin-top: 32px;
width: 750px;
align-items: center;
}
.a-flex {
display: flex;
flex-direction: row;
justify-content: space-around;
margin-bottom: 60px;
}
.w-96 {
width: 96px;
}
.loading-img {
width: 32px;
height: 32px;
}
.h-100 {
width: 750px;
height: 100px;
}
</style>
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
# Attributes
Prop | Type | Default | Description |
---|---|---|---|
sliderStyle | Object | 见注1 | 滑动条样式 |
items | Array | 见注2 | 图片数据 |
interval | Number | 3000 | 轮播间隔 |
indicatorStyle | Object | 见注3 | 点样式(可参考weex) |
autoplay | Boolean | true | 是否自动播放 |
infinite | Boolean | true | 是否循环播放 |
imgResize | String | stretch | 参考<image> 中的resize属性 |
imgHeight | String | 280px | 图片高度 |
imgWidth | String | 686px | 图片宽度 |
divLeft | String | 32px | 盒子距最左屏幕的间距 |
showIndicator | Boolean | true | 是否出现点(索引) |
- 注1:
sliderStyle: {
'width': '702px',
'height': '400px',
'position': 'relative'
}
1
2
3
4
5
2
3
4
5
- 注2:
items: [
{ title: 'item A', url: 'https://gd2.alicdn.com/bao/uploaded/i2/T14H1LFwBcXXXXXXXX_!!0-item_pic.jpg' },
{ title: 'item B', url: 'https://gd1.alicdn.com/bao/uploaded/i1/TB1PXJCJFXXXXciXFXXXXXXXXXX_!!0-item_pic.jpg' },
{ title: 'item C', url: 'https://gd3.alicdn.com/bao/uploaded/i3/TB1x6hYLXXXXXazXVXXXXXXXXXX_!!0-item_pic.jpg' }
]
1
2
3
4
5
2
3
4
5
- 注3:
indicatorStyle: {
itemColor: rgba(255, 255, 255, .5), //未选中时的颜色
itemSelectedColor: rgba(255, 255, 255, 1), //选中时的颜色
itemSize: 12px //点半径
}
1
2
3
4
5
2
3
4
5
# Events
事件名称 | 说明 | 回调参数 |
---|---|---|
dofSwiperClicked | 轮播图点击事件 | event : {target , index },target:当前图片信息,index:当前索引 |