mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
* [bugfix] Checkbox border render error in weixin browser * [bugfix] TreeSelect dependency path error * [bugfix] Swipe should clear autoplay timer when destroyed
1.8 KiB
1.8 KiB
Swipe
Install
import { Swipe, SwipeItem } from 'vant';
Vue.component(Swipe.name, Swipe);
Vue.component(SwipeItem.name, SwipeItem);
Usage
Basic Usage
通过autoplay
属性设置自动轮播间隔
:::demo Basic Usage
<van-swipe :autoplay="3000">
<van-swipe-item>1</van-swipe-item>
<van-swipe-item>2</van-swipe-item>
<van-swipe-item>3</van-swipe-item>
<van-swipe-item>4</van-swipe-item>
</van-swipe>
:::
图片懒加载
配合 Lazyload 组件实现图片懒加载
:::demo 图片懒加载
<van-swipe>
<van-swipe-item v-for="(image, index) in images" :key="index">
<img v-lazy="image" />
</van-swipe-item>
</van-swipe>
export default {
data() {
return {
images: [
'https://img.yzcdn.cn/1.jpg',
'https://img.yzcdn.cn/2.jpg'
]
}
}
}
:::
API
Attribute | Description | Type | Default | Accepted Values |
---|---|---|---|---|
autoplay | 自动轮播间隔,单位为 ms | Number |
- | - |
duration | 动画时长,单位为 ms | Number |
500 |
- |
showIndicators | 是否显示指示器 | Boolean |
true |
- |
事件
Event | Description | Attribute |
---|---|---|
change | 每一页轮播结束后触发 | index, 当前页的索引 |