mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
* [bugfix] CouponList always show empty info * [bugfix] add click feedback of buttons in components * [Doc] add custom theme document * [new feature] Notice bar support more props * [bugfix] PullRefresh test cases * [bugfix] unused NoticeBar style * [bugfix] Swipe width calc error * [Doc] english document of all action components * [Doc] change document site path to /zanui/vant * [Doc] fix * [bugfix] uploader style error * [bugfix] tabs document demo * [new feature] Cell support vue-router target route * [bugfix] add cell test cases * update yarn.lock * [bugfix] Tabbar cann't display info when use icon slot * [Doc] update document title * [bugfix] Dialog should reset button text when showed * [new feature] CouponList add showCloseButton prop * [new feature] Swipe add 'initialSwipe' prop
118 lines
2.5 KiB
Markdown
118 lines
2.5 KiB
Markdown
<style>
|
|
.demo-swipe {
|
|
padding-bottom: 30px;
|
|
|
|
.van-swipe {
|
|
cursor: pointer;
|
|
|
|
&-item {
|
|
color: #fff;
|
|
min-height: 140px;
|
|
font-size: 20px;
|
|
text-align: center;
|
|
line-height: 150px;
|
|
|
|
&:nth-child(even) {
|
|
background-color: #39a9ed;
|
|
}
|
|
|
|
&:nth-child(odd) {
|
|
background-color: #66c6f2;
|
|
}
|
|
}
|
|
|
|
img {
|
|
width: 100%;
|
|
height: 240px;
|
|
display: block;
|
|
padding: 30px 60px;
|
|
box-sizing: border-box;
|
|
background-color: #fff;
|
|
pointer-events: none;
|
|
}
|
|
}
|
|
}
|
|
</style>
|
|
|
|
<script>
|
|
export default {
|
|
data() {
|
|
return {
|
|
images: [
|
|
'https://img.yzcdn.cn/public_files/2017/09/05/3bd347e44233a868c99cf0fe560232be.jpg',
|
|
'https://img.yzcdn.cn/public_files/2017/09/05/c0dab461920687911536621b345a0bc9.jpg',
|
|
'https://img.yzcdn.cn/public_files/2017/09/05/4e3ea0898b1c2c416eec8c11c5360833.jpg',
|
|
'https://img.yzcdn.cn/public_files/2017/09/05/fd08f07665ed67d50e11b32a21ce0682.jpg'
|
|
]
|
|
};
|
|
}
|
|
};
|
|
</script>
|
|
|
|
## Swipe 轮播
|
|
|
|
### 使用指南
|
|
``` javascript
|
|
import { Swipe, SwipeItem } from 'vant';
|
|
|
|
Vue.component(Swipe.name, Swipe);
|
|
Vue.component(SwipeItem.name, SwipeItem);
|
|
```
|
|
|
|
### 代码演示
|
|
|
|
#### 基础用法
|
|
通过`autoplay`属性设置自动轮播间隔
|
|
|
|
:::demo 基础用法
|
|
```html
|
|
<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](#/zh-CN/component/lazyload) 组件实现图片懒加载
|
|
|
|
:::demo 图片懒加载
|
|
```html
|
|
<van-swipe :autoplay="3000">
|
|
<van-swipe-item v-for="(image, index) in images" :key="index">
|
|
<img v-lazy="image" />
|
|
</van-swipe-item>
|
|
</van-swipe>
|
|
```
|
|
|
|
```javascript
|
|
export default {
|
|
data() {
|
|
return {
|
|
images: [
|
|
'https://img.yzcdn.cn/1.jpg',
|
|
'https://img.yzcdn.cn/2.jpg'
|
|
]
|
|
}
|
|
}
|
|
}
|
|
```
|
|
:::
|
|
|
|
### API
|
|
|
|
| 参数 | 说明 | 类型 | 默认值 | 可选值 |
|
|
|-----------|-----------|-----------|-------------|-------------|
|
|
| autoplay | 自动轮播间隔,单位为 ms | `Number` | - | - |
|
|
| duration | 动画时长,单位为 ms | `Number` | `500` | - |
|
|
| showIndicators | 是否显示指示器 | `Boolean` | `true` | - |
|
|
| initialSwipe | 初始位置,从 0 开始算 | `Number` | `0` | - |
|
|
|
|
### 事件
|
|
|
|
| 事件名 | 说明 | 参数 |
|
|
|-----------|-----------|-----------|
|
|
| change | 每一页轮播结束后触发 | index, 当前页的索引 |
|