| item | desc |
|---|---|
| indicator-dots | 指示器 |
| indicator-color | 指示器颜色 |
| indicator-active-color | 当前指示器颜色 |
| autoplay | 自动播放;false |
| current | 当前项目索引;0 |
| interval | 自动切换时间间隔;5000 |
| duration | 滑动动画时长;500 |
| circular | 是否采用衔接滑动;false |
| vertical | 纵向;false |
| bindchange | current 改变时会触发;可以获取当前项:e.detail.current |
| bindtransition | swiper-item 的位置发生改变时会触发 |
| bindanimationfinish | 动画结束时会触发 |
wx.request({
url: 'https://glpla.github.io/utils/data/swiper.json',
success: res => {
console.log('res', res);
this.setData({
imgs: res.data.cont
})
}
})
<swiper class="swiper" indicator-dots indicator-color="#fff" indicator-active-color="#f40" autoplay circular>
<swiper-item class="swiper-item" wx:for="{{imgs}}" wx:key="id">
<image class="img" src="{{item.url}}" mode="aspectFill" />
</swiper-item>
</swiper>
.swiper{
height: 30vh;
}
.img{
width: 100%;
}