diff --git a/docs/examples-dist/button.vue b/docs/examples-dist/button.vue
index ecbc26d0f..3295b1f38 100644
--- a/docs/examples-dist/button.vue
+++ b/docs/examples-dist/button.vue
@@ -53,13 +53,6 @@
-
-
- 确认付款
- 确认收货
- 取消订单
-
-
+
+
## Swipe 轮播
### 基础用法
@@ -33,7 +43,7 @@
:::demo 自动轮播
```html
-
+
@@ -43,3 +53,16 @@
```
:::
+
+### API
+
+| 参数 | 说明 | 类型 | 默认值 | 可选值 |
+|-----------|-----------|-----------|-------------|-------------|
+| autoPlay | 是否自动轮播 | `boolean` | `false` | `true`, `false` |
+| showIndicators | 是否显示指示器 | `boolean` | `true` | `true`, `false` |
+
+### 事件
+
+| 事件名 | 说明 | 参数 |
+|-----------|-----------|-----------|
+| `pagechange:end` | 每一页轮播结束后触发 | `(elem, currIndex)`:`elem`为触发页当前的DOM节点 |
diff --git a/packages/swipe/src/swipe-item.vue b/packages/swipe/src/swipe-item.vue
index 0a7ea92b5..2d8575839 100644
--- a/packages/swipe/src/swipe-item.vue
+++ b/packages/swipe/src/swipe-item.vue
@@ -6,6 +6,11 @@
diff --git a/packages/swipe/src/swipe.vue b/packages/swipe/src/swipe.vue
index 83e641a6a..0d7c5b229 100644
--- a/packages/swipe/src/swipe.vue
+++ b/packages/swipe/src/swipe.vue
@@ -1,6 +1,14 @@
@@ -13,13 +21,17 @@ export default {
name: 'zan-swipe',
props: {
- autoPlay: {
+ autoPlay: Boolean,
+ showIndicators: {
type: Boolean,
- default: false
- },
- onPageChangeEnd: {
- type: Function,
- default: () => {}
+ default: true
+ }
+ },
+
+ data() {
+ return {
+ currIndex: 0,
+ swipes: []
}
},
@@ -53,6 +65,13 @@ export default {
updated() {
this.scroll.update();
+ },
+
+ methods: {
+ onPageChangeEnd(page, currIndex) {
+ this.currIndex = +currIndex;
+ this.$emit('pagechange:end', page, currIndex);
+ }
}
};
diff --git a/packages/zanui-css/src/swipe.css b/packages/zanui-css/src/swipe.css
index e5af9411f..2c092278e 100644
--- a/packages/zanui-css/src/swipe.css
+++ b/packages/zanui-css/src/swipe.css
@@ -1,24 +1,49 @@
+@import './common/var.css';
+
@component-namespace zan {
- @b swipe {
- position: relative;
- overflow: hidden;
- width: 100%;
+ @b swipe {
+ position: relative;
+ overflow: hidden;
+ width: 100%;
+
+ @e indicators {
+ position: absolute;
+ bottom: 10px;
+ left: 50%;
+ transform: translateX(-50%);
}
- @b swipe-item {
- display: none;
- width: 100%;
- height: 100%;
- overflow: hidden;
- text-align: center;
+ @e indicator {
+ width: 5px;
+ height: 5px;
+ display: inline-block;
+ border-radius: 100%;
+ background: #000;
+ opacity: .2;
+ margin: 0 3px;
+ z-index: 1;
- img {
- width: 100%;
- height: auto;
- }
-
- &:first-child {
- display: block;
- }
+ @m active {
+ background: $c-orange;
+ opacity: 1;
+ }
}
+ }
+
+ @b swipe-item {
+ display: none;
+ width: 100%;
+ height: 100%;
+ overflow: hidden;
+ text-align: center;
+
+ img {
+ width: 100%;
+ height: auto;
+ }
+
+ &:first-child {
+ display: block;
+ }
+ }
}