swiper去除滑动设置

时间:2022-04-04 16:29:06

有时候使用swiper并不想让它滑动,怎么设置呢?

1.noSwiping设为true

2.在slide上(或其他元素)增加类名'swiper-no-swiping',使该slide无法拖动。

案例:

<div class="swiper-container">
<div class="swiper-wrapper">
<div class="swiper-slide swiper-no-swiping">
slider1</div>
<div class="swiper-slide swiper-no-swiping">
slider2</div>
<div class="swiper-slide swiper-no-swiping">
slider3</div>
</div>
</div>
<script language="javascript">
var mySwiper = new Swiper('.swiper-container',{
noSwiping : true,
})
</script>