From 2073853e87f9d5d8d39f204bc9293da1a8782b07 Mon Sep 17 00:00:00 2001 From: 梁灏 Date: Wed, 28 Feb 2018 15:38:20 +0800 Subject: [PATCH] fixed #3038 --- examples/routers/carousel.vue | 45 +++++++++++++++++++++------------------------ src/components/carousel/carousel.vue | 11 +++++------ 2 files changed, 26 insertions(+), 30 deletions(-) diff --git a/examples/routers/carousel.vue b/examples/routers/carousel.vue index 7f4383d..e8e411f 100644 --- a/examples/routers/carousel.vue +++ b/examples/routers/carousel.vue @@ -1,21 +1,23 @@ - \ No newline at end of file + + diff --git a/src/components/carousel/carousel.vue b/src/components/carousel/carousel.vue index b4771c6..b8d1c58 100644 --- a/src/components/carousel/carousel.vue +++ b/src/components/carousel/carousel.vue @@ -243,8 +243,8 @@ this.updateTrackPos(this.hideTrackPos); } // 获取当前展示图片的索引值 - let index = this.showCopyTrack ? this.copyTrackIndex : this.trackIndex; - index += offset; + const oldIndex = this.showCopyTrack ? this.copyTrackIndex : this.trackIndex; + let index = oldIndex + offset; while (index < 0) index += slidesLen; if (((offset > 0 && index === slidesLen) || (offset < 0 && index === slidesLen - 1)) && this.loop) { // 极限值(左滑:当前索引为总图片张数, 右滑:当前索引为总图片张数 - 1)切换轨道 @@ -255,7 +255,9 @@ if (!this.loop) index = index % this.slides.length; this.updateTrackIndex(index); } - this.$emit('input', index === this.slides.length ? 0 : index); + this.currentIndex = index === this.slides.length ? 0 : index; + this.$emit('on-change', oldIndex, this.currentIndex); + this.$emit('input', this.currentIndex); }, arrowEvent (offset) { this.setAutoplay(); @@ -294,9 +296,6 @@ autoplaySpeed () { this.setAutoplay(); }, - currentIndex (val, oldVal) { - this.$emit('on-change', oldVal, val); - }, trackIndex () { this.updateOffset(); }, -- libgit2 0.21.4