简体   繁体   English

如何在 swiper slider 中禁用拖动

[英]How to disable drag in swiper slider

I am using swiper slider version 3.3.1.我正在使用 swiper slider 版本 3.3.1。 I did apply this code, but not working我确实应用了这段代码,但没有工作

var swiper = new Swiper('.swiper', {
    speed: 400,
    autoHeight: false,
    loop: true,
    autoplay: 2500,
    autoplayStopOnLast: false, 
    pagination: '.swiper-pagination',
    paginationType: "bullets",
    simulateTouch:false, 
    nextButton: '.swiper-button-next',
    prevButton: '.swiper-button-prev',
    effect: 'fade',
    slidesPerView: 1,
    scrollbar: {
     container: '.swiper-scrollbar',
     draggable: false,
   }
});

I am using swiper slider version 3.3.1.我正在使用3.3.1版的swiper滑块。 I did apply this code, but not working我确实应用了此代码,但无法正常工作

var swiper = new Swiper('.swiper', {
    speed: 400,
    autoHeight: false,
    loop: true,
    autoplay: 2500,
    autoplayStopOnLast: false, 
    pagination: '.swiper-pagination',
    paginationType: "bullets",
    simulateTouch:false, 
    nextButton: '.swiper-button-next',
    prevButton: '.swiper-button-prev',
    effect: 'fade',
    slidesPerView: 1,
    scrollbar: {
     container: '.swiper-scrollbar',
     draggable: false,
   }
});

To add onto Veronica's answer, you can set allowTouchMove: false as a parameter for the Swiper.要添加到 Veronica 的答案,您可以将allowTouchMove: false设置为 Swiper 的参数。

Example in React: React 中的示例:

<Swiper
  allowTouchMove={false} // disable touch / drag swiping
  {...swiperProps}
>
  {...slides}
</Swiper>

You can read more in the Swiper Documentation您可以在Swiper 文档中阅读更多内容

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM