关于swiper的滚动条滑动

时间:2023-03-08 18:22:23
关于swiper的滚动条滑动

<div class="swiper-container2">
<div class="swiper-wrapper">
<div class="swiper-slide">
<div class="swiper-slide-img">4</div>
<div class="swiper-slide-price"></div>
</div>
<div class="swiper-slide">
<div class="swiper-slide-img">1</div>
<div class="swiper-slide-price"></div>
</div>
<div class="swiper-slide">
<div class="swiper-slide-img">2</div>
<div class="swiper-slide-price"></div>
</div>
<div class="swiper-slide">
<div class="swiper-slide-img">3</div>
<div class="swiper-slide-price"></div>
</div>
</div>
</div>

var swiper = new Swiper('.swiper-container2', {
scrollbarHide: true,
slidesPerView :"auto",
spaceBetween:15,
});

if (swiper.slides.length<4) {
swiper.detachEvents();
}

关于swiper的滚动条滑动

当图片数量小于4时整个滚动,停止,

反之大于4时,图片可以滚动,图片间距设置15