Swiper
Slider view container with indicator dots, autoplay, and loop support.
Attributes
|
Attribute |
Type |
Default value |
Description |
Minimum version |
|
indicator-dots |
Boolean |
false |
Shows indicator dots. |
- |
|
indicator-color |
Color |
rgba(0, 0, 0, .3) |
Color of inactive indicator dots. |
- |
|
indicator-active-color |
Color |
#000 |
Color of the active indicator dot. |
- |
|
active-class |
String |
- |
CSS |
|
|
changing-class |
String |
- |
CSS |
|
|
autoplay |
Boolean |
false |
Enables automatic slide switching. |
- |
|
current |
Number |
0 |
Index of the current slide. |
- |
|
duration |
Number |
500 (ms) |
Slide animation duration in milliseconds. |
- |
|
interval |
Number |
5000 (ms) |
Autoplay interval in milliseconds. |
- |
|
circular |
Boolean |
false |
Enables infinite loop sliding. |
- |
|
vertical |
Boolean |
false |
Enables vertical sliding. |
- |
|
previous-margin |
String |
‘0px’ |
Leading margin in px. Horizontal only as of 1.9.0. |
|
|
next-margin |
String |
‘0px’ |
Trailing margin in px. Horizontal only as of 1.9.0. |
|
|
acceleration |
Boolean |
false |
Enables velocity-based multi-screen sliding. |
|
|
disable-programmatic-animation |
Boolean |
false |
Disables animation for programmatic slide changes. |
|
|
onChange |
EventHandle |
- |
Fires when |
- |
|
onTransition |
EventHandle |
- |
Fires when a |
|
|
onAnimationEnd |
EventHandle |
- |
Fires when slide animation ends. |
|
|
disable-touch |
Boolean |
false |
Disables touch-based sliding. |
swiper-item
Must be nested in a swiper component. Width and height auto-set to 100%.
Legend

Code example
<swiper
indicator-dots="{{indicatorDots}}"
autoplay="{{autoplay}}"
interval="{{interval}}"
>
<block a:for="{{background}}">
<swiper-item>
<view class="swiper-item bc_{{item}}"></view>
</swiper-item>
</block>
</swiper>
<view class="btn-area">
<button class="btn-area-button" type="default" onTap="changeIndicatorDots">indicator-dots</button>
<button class="btn-area-button" type="default" onTap="changeAutoplay">autoplay</button>
</view>
<slider onChange="intervalChange" value="{{interval}}" show-value min="2000" max="10000"/>
<view class="section__title">interval</view>Page({
data: {
background: ['green', 'red', 'yellow'],
indicatorDots: true,
autoplay: false,
interval: 3000,
},
changeIndicatorDots(e) {
this.setData({
indicatorDots: !this.data.indicatorDots
})
},
changeAutoplay(e) {
this.setData({
autoplay: !this.data.autoplay
})
},
intervalChange(e) {
this.setData({
interval: e.detail.value
})
},
})