diff --git a/docs/examples-docs/en-US/swipe.md b/docs/examples-docs/en-US/swipe.md index 57fa76f6d..5c2287909 100644 --- a/docs/examples-docs/en-US/swipe.md +++ b/docs/examples-docs/en-US/swipe.md @@ -72,6 +72,7 @@ export default { | autoplay | Autoplay interval (ms) | `Number` | - | - | | duration | Animation duration (ms) | `Number` | `500` | - | | showIndicators | Whether to show indocators | `Boolean` | `true` | - | +| initialSwipe | Index of initial swipe, start from 0 | `Number` | `0` | - | ### Event diff --git a/docs/examples-docs/zh-CN/swipe.md b/docs/examples-docs/zh-CN/swipe.md index 26d014a68..5470707b8 100644 --- a/docs/examples-docs/zh-CN/swipe.md +++ b/docs/examples-docs/zh-CN/swipe.md @@ -80,7 +80,7 @@ Vue.component(SwipeItem.name, SwipeItem); :::demo 图片懒加载 ```html - + @@ -108,6 +108,7 @@ export default { | autoplay | 自动轮播间隔,单位为 ms | `Number` | - | - | | duration | 动画时长,单位为 ms | `Number` | `500` | - | | showIndicators | 是否显示指示器 | `Boolean` | `true` | - | +| initialSwipe | 初始位置,从 0 开始算 | `Number` | `0` | - | ### 事件 diff --git a/packages/swipe/index.vue b/packages/swipe/index.vue index ca9e427d1..f0af6ec74 100644 --- a/packages/swipe/index.vue +++ b/packages/swipe/index.vue @@ -30,6 +30,10 @@ export default { props: { autoplay: Number, + initialSwipe: { + type: Number, + default: 0 + }, showIndicators: { type: Boolean, default: true @@ -92,9 +96,9 @@ export default { // reset offset when children changes clearTimeout(this.timer); this.width = this.$el.getBoundingClientRect().width; - this.active = 0; + this.active = this.initialSwipe; this.currentDuration = 0; - this.offset = this.count > 1 ? -this.width : 0; + this.offset = this.count > 1 ? -this.width * (this.active + 1) : 0; this.swipes.forEach(swipe => { swipe.offset = 0; });