fixed #3038
This commit is contained in:
parent
ab3ff750a3
commit
2073853e87
2 changed files with 26 additions and 30 deletions
|
@ -1,21 +1,23 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<Carousel v-model="v1" dots="inside" trigger="hover" autoplay loop radius-dot easing="fade">
|
<Carousel v-model="v1" dots="outside" @on-change="hc" :autoplay="false">
|
||||||
<Carousel-item>
|
<Carousel-item>
|
||||||
<div class="demo-carousel">1</div>
|
<div class="demo-case-img">
|
||||||
|
<img src="https://file.iviewui.com/dist/84b3cded4163febf9dae090e76129322.png">
|
||||||
|
</div>
|
||||||
</Carousel-item>
|
</Carousel-item>
|
||||||
<Carousel-item>
|
<Carousel-item>
|
||||||
<div class="demo-carousel">2</div>
|
<div class="demo-case-img">
|
||||||
|
<img src="https://file.iviewui.com/dist/84b3cded4163febf9dae090e76129322.png">
|
||||||
|
</div>
|
||||||
</Carousel-item>
|
</Carousel-item>
|
||||||
<Carousel-item>
|
<Carousel-item>
|
||||||
<div class="demo-carousel">3</div>
|
<div class="demo-case-img">
|
||||||
</Carousel-item>
|
<img src="https://file.iviewui.com/dist/84b3cded4163febf9dae090e76129322.png">
|
||||||
<Carousel-item>
|
</div>
|
||||||
<div class="demo-carousel">4</div>
|
|
||||||
</Carousel-item>
|
</Carousel-item>
|
||||||
</Carousel>
|
</Carousel>
|
||||||
{{ v1 }}
|
<Button @click="v1 = 2">change</Button>
|
||||||
<div @click="v1 = 0">change v1</div>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
|
@ -23,25 +25,20 @@
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
v1: 0
|
v1: 0
|
||||||
};
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
push () {
|
hc (...args) {
|
||||||
this.pushItem.push('test');
|
console.log(args);
|
||||||
},
|
|
||||||
slideChange (from, to) {
|
|
||||||
this.log.push(`From ${from} To ${to}`);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style>
|
<style lang="less">
|
||||||
.demo-carousel{
|
.demo-case-img {
|
||||||
height: 200px;
|
img{
|
||||||
line-height: 200px;
|
width: 500px;
|
||||||
text-align: center;
|
}
|
||||||
color: #fff;
|
|
||||||
font-size: 20px;
|
|
||||||
background: #506b9e;
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
|
@ -243,8 +243,8 @@
|
||||||
this.updateTrackPos(this.hideTrackPos);
|
this.updateTrackPos(this.hideTrackPos);
|
||||||
}
|
}
|
||||||
// 获取当前展示图片的索引值
|
// 获取当前展示图片的索引值
|
||||||
let index = this.showCopyTrack ? this.copyTrackIndex : this.trackIndex;
|
const oldIndex = this.showCopyTrack ? this.copyTrackIndex : this.trackIndex;
|
||||||
index += offset;
|
let index = oldIndex + offset;
|
||||||
while (index < 0) index += slidesLen;
|
while (index < 0) index += slidesLen;
|
||||||
if (((offset > 0 && index === slidesLen) || (offset < 0 && index === slidesLen - 1)) && this.loop) {
|
if (((offset > 0 && index === slidesLen) || (offset < 0 && index === slidesLen - 1)) && this.loop) {
|
||||||
// 极限值(左滑:当前索引为总图片张数, 右滑:当前索引为总图片张数 - 1)切换轨道
|
// 极限值(左滑:当前索引为总图片张数, 右滑:当前索引为总图片张数 - 1)切换轨道
|
||||||
|
@ -255,7 +255,9 @@
|
||||||
if (!this.loop) index = index % this.slides.length;
|
if (!this.loop) index = index % this.slides.length;
|
||||||
this.updateTrackIndex(index);
|
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) {
|
arrowEvent (offset) {
|
||||||
this.setAutoplay();
|
this.setAutoplay();
|
||||||
|
@ -294,9 +296,6 @@
|
||||||
autoplaySpeed () {
|
autoplaySpeed () {
|
||||||
this.setAutoplay();
|
this.setAutoplay();
|
||||||
},
|
},
|
||||||
currentIndex (val, oldVal) {
|
|
||||||
this.$emit('on-change', oldVal, val);
|
|
||||||
},
|
|
||||||
trackIndex () {
|
trackIndex () {
|
||||||
this.updateOffset();
|
this.updateOffset();
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Reference in a new issue