如何使用 swiperjs 防止在某些幻灯片上滑动

How to prevent swiping on certain are of the slide using swiperjs

我们正在使用 swiperjs 幻灯片。它运行良好,但我们在幻灯片中有 input,如果用户实际上可以在这些输入上滑动,则很难填充输入。我想知道如果用户在输入上触摸启动,是否有办法防止滑块滑动。

这是我们初始化滑块的方式:

new Swiper('.slider', {
  resistance: true,
  resistanceRatio: 25,
});

幻灯片里面的HTML包括

<input type="text">
<input type='range' min='0' max='11'>

在回答这个问题时,以后会有人遇到同样的问题。

只需在不可滑动的元素上添加 swiper-no-swiping class 或更改 noSwipingClass 参数即可。