swiper设置slidesPerView:3;
但是点击其他两个只会触发最前面的点击事件,这是什么原因?
<swiper class="swiper" :options="swiperOption">
<swiper-slide v-for="(item, index) in img.all" :key="index">
<img :src="item" alt/>
</swiper-slide>
</swiper>
swiperOption: {
loop: true,
slidesPerView: 3,
observer: true,
observerParents: true,
on: {
click: function (e) {
console.log('点击事件', e)
const realIndex = this.realIndex
console.log('realIndex', realIndex)
vm.click(realIndex)
}
}
}
不论点哪个,realIndex 都是0,但是向左滑动一格后,都是1,再滑动都是2,以此类推