swiper
滑块视图容器。
属性
支持通用属性
| 属性名 | 类型 | 默认值 | 说明 | 平台支持 |
|---|---|---|---|---|
| indicator-dots | Boolean | false | 是否显示面板指示点 | all |
| indicator-color | Color | rgba(0, 0, 0, .3) | 指示点颜色 | all |
| indicator-active-color | Color | #000000 | 当前选中的指示点颜色 | all |
| autoplay | Boolean | false | 是否自动切换 | all |
| current | Number | 0 | 当前所在页面的 index | all |
| interval | Number | 5000 | 自动切换时间间隔 | all |
| duration | Number | 500 | 滑动动画时长 | u?,w,a |
| vertical | Boolean | false | 滑动方向是否为纵向 | w |
事件
支持通用事件
| 事件名 | 描述 | 平台支持 |
|---|---|---|
| onchange | current改变时触发,event.detail={current:current} | all |
swiper-item
仅可放置在<swiper/>组件中,宽高自动设置为100%。
示例
<swiper indicator-dots=""
autoplay="" interval="" duration="">
<block for="">
<swiper-item>
<image src="" class="slide-image" width="355" height="150"/>
</swiper-item>
</block>
</swiper>
<button onclick="changeIndicatorDots"> indicator-dots </button>
<button onclick="changeAutoplay"> autoplay </button>
<slider onchange="intervalChange" show-value min="500" max="2000"/> interval
<slider onchange="durationChange" show-value min="1000" max="10000"/> duration
Page({
data: {
imgUrls: [
'http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg',
'http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg',
'http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg'
],
indicatorDots: false,
autoplay: false,
interval: 5000,
duration: 1000
},
changeIndicatorDots: function(e) {
this.setData({
indicatorDots: !this.data.indicatorDots
})
},
changeAutoplay: function(e) {
this.setData({
autoplay: !this.data.autoplay
})
},
intervalChange: function(e) {
this.setData({
interval: e.detail.value
})
},
durationChange: function(e) {
this.setData({
duration: e.detail.value
})
}
})