# 10.1 轮播图(Swiper)
# dof-swiper
轮播图组件
# 实例
# 基础用法
<template>
<div class="wrapper">
<dof-minibar
title="Swiper"
background-color="#267AFF"
text-color="#ffffff"
:left-button="leftButton"
@dofMinibarLeftButtonClicked="back"
v-once
>
<div slot="right" class="right-img-wrapper">
<dof-icon
:iconStyle="{ fontSize: '32px', color: '#fff' }"
name="refresh"
@dofIconClicked="reloadHandler"
></dof-icon>
</div>
</dof-minibar>
<scroller>
<title title="dof-swiper"></title>
<category title="有圆点 小banner"></category>
<dof-swiper :sliderStyle="{ height: '180px' }" imgHeight="180px" :items="items0" class="mar_top"> </dof-swiper>
<div class="div_sty"></div>
<category title="有圆点 常用banner高度1"></category>
<dof-swiper :sliderStyle="{ height: '280px' }" imgHeight="280px" :items="items1" class="mar_top"> </dof-swiper>
<div class="div_sty"></div>
<category title="有圆点 常用banner高度2"></category>
<dof-swiper :sliderStyle="{ height: '386px' }" imgHeight="386px" :items="items2" class="mar_top"> </dof-swiper>
<div class="div_sty"></div>
<category title="有圆点 小banner 限制10张图片"></category>
<dof-swiper :sliderStyle="{ height: '180px' }" imgHeight="180px" :items="items3" class="mar_top"> </dof-swiper>
<div class="div_sty"></div>
</scroller>
</div>
</template>
<style scoped>
.div_sty {
width: 750px;
height: 25px;
}
.mar_top {
margin-top: 25px;
}
</style>
<script>
import { DofMinibar, DofIcon, DofButton, DofSwiper, Core } from 'dolphin-weex-ui'
import Title from 'src/_mods/title.vue'
import Category from 'src/_mods/catalog'
import { setTitle } from 'src/_mods/set-nav'
export default {
components: { DofSwiper, Title, Category, DofButton, DofMinibar, DofIcon },
// mixins: [base],
data() {
return {
showIndicator: false,
leftButton: '/assets/image/header/icon_back_white@3x.png',
items0: [
{
title: 'item1',
url: 'http://dolphin-weex-dev.msmartlife.cn/cdn/images/ui_library/swipe/IMG20200731-152510859.png'
},
{
title: 'item2',
url: 'http://dolphin-weex-dev.msmartlife.cn/cdn/images/ui_library/swipe/IMG20200731-152448695.png'
},
{
title: 'item3',
url: 'http://dolphin-weex-dev.msmartlife.cn/cdn/images/ui_library/swipe/IMG20200731-152514533.png'
}
],
items1: [
{ title: 'item1',
url: 'http://dolphin-weex-dev.msmartlife.cn/cdn/images/ui_library/swipe/IMG20200731-152510859.png'
},
{
title: 'item2',
url: 'http://dolphin-weex-dev.msmartlife.cn/cdn/images/ui_library/swipe/IMG20200731-160840730.jpg'
},
{
title: 'item3',
url: 'http://dolphin-weex-dev.msmartlife.cn/cdn/images/ui_library/swipe/IMG20200731-160801298.png'
}
],
items2: [
{
title: 'item1',
url: 'http://dolphin-weex-dev.msmartlife.cn/cdn/images/ui_library/swipe/IMG20200731-152522918.png'
},
{
title: 'item2',
url: 'http://dolphin-weex-dev.msmartlife.cn/cdn/images/ui_library/swipe/IMG20200731-160739420.jpg'
},
{
title: 'item3',
url: 'http://dolphin-weex-dev.msmartlife.cn/cdn/images/ui_library/swipe/IMG20200731-160745218.jpg'
}
],
items3: [
{
title: 'item1',
url: 'http://dolphin-weex-dev.msmartlife.cn/cdn/images/ui_library/swipe/IMG20200731-152448695.png'
},
{
title: 'item2',
url: 'http://dolphin-weex-dev.msmartlife.cn/cdn/images/ui_library/swipe/IMG20200731-152510859.png'
},
{
title: 'item3',
url: 'http://dolphin-weex-dev.msmartlife.cn/cdn/images/ui_library/swipe/IMG20200731-152514533.png'
},
{
title: 'item4',
url: 'http://dolphin-weex-dev.msmartlife.cn/cdn/images/ui_library/swipe/IMG20200731-152518708.png'
},
{
title: 'item5',
url: 'http://dolphin-weex-dev.msmartlife.cn/cdn/images/ui_library/swipe/IMG20200731-152525995.png'
},
{
title: 'item6',
url: 'http://dolphin-weex-dev.msmartlife.cn/cdn/images/ui_library/swipe/IMG20200731-160824117.jpg'
},
{
title: 'item7',
url: 'http://dolphin-weex-dev.msmartlife.cn/cdn/images/ui_library/swipe/IMG20200731-160844222.jpg'
},
{
title: 'item8',
url: 'http://dolphin-weex-dev.msmartlife.cn/cdn/images/ui_library/swipe/IMG20200731-152448695.png'
},
{
title: 'item9',
url: 'http://dolphin-weex-dev.msmartlife.cn/cdn/images/ui_library/swipe/IMG20200731-152510859.png'
},
{
title: 'item10',
url: 'http://dolphin-weex-dev.msmartlife.cn/cdn/images/ui_library/swipe/IMG20200731-152514533.png'
},
{
title: 'item11',
url: 'http://dolphin-weex-dev.msmartlife.cn/cdn/images/ui_library/swipe/IMG20200731-152525995.png'
},
{
title: 'item12',
url: 'http://dolphin-weex-dev.msmartlife.cn/cdn/images/ui_library/swipe/IMG20200731-160824117.jpg'
}
],
items4: [
{ title: 'item1', url: 'http://dolphin-weex-dev.msmartlife.cn/cdn/images/ui_library/swipe/004.png' },
{ title: 'item2', url: 'http://dolphin-weex-dev.msmartlife.cn/cdn/images/ui_library/swipe/004.png' },
{ title: 'item3', url: 'http://dolphin-weex-dev.msmartlife.cn/cdn/images/ui_library/swipe/004.png' }
]
}
},
methods: {
onchange(event) {
console.log('changed:', event.index)
},
back() {},
reloadHandler() {
Core.reload()
}
},
created() {
setTitle('Swiper')
}
}
</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
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
# 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:当前索引 |