做了一个点击放大图片效果,但是当轮播到第二遍的时候第一张图就无法点击了,是为什么?
顺便问下swiper4怎么用懒加载图,我设置lazyLoadin为true为什么没效果?
现在怀疑是loop作怪,求大神
<swiper :options="swiperOption" ref="mySwiper">
<swiper-slide v-for="(img,index) in banner" :key="index">
<img :src="img.src" alt="" @click="select(index)"
:class="{big: index===selectIndex}">
</swiper-slide>
<div class="swiper-pagination" slot="pagination"></div>
<!-- <div class="swiper-button-prev" slot="button-prev"></div>
<div class="swiper-button-next" slot="button-next"></div> -->
</swiper>
data{
swiperOption: {
loop: true,
lazyLoading: {
lazyLoading: true,
lazyLoadingInPrevNext: true,
},
autoplay: {
disableOnInteraction: false,
stopOnLastSlide: true
},
// 如果需要分页器
pagination: {
el: ".swiper-pagination",
clickable: true
}
},
selectIndex: undefined,
},
methods: {
select (index) {
this.selectIndex = this.selectIndex === index ? undefined : index;
console.log(this.selectIndex === index);
}
}
click事件写在swiper-slide上试试
click.native="select(index)"