swiper React 阻止移动设备上通过触摸(滑动)滚动网页

问题描述 投票:0回答:1

我在我的应用程序中创建了 3 个滑动器,只有这个不允许我通过滑动来滚动网站,以下是我为此滑动器设置的设置:

<Swiper
        allowTouchMove={false}
        effect={'fade'}
        direction={'vertical'}
        slidesPerView={1}
        loop={false}
        pagination={{
          clickable: true,
          el: '.swiper-pagination',
        }}
        autoplay={{
          delay: 5000,
          disableOnInteraction: false,
        }}
        modules={[EffectFade, Navigation, Pagination, Autoplay]}
        style={{
          width: '100%',
          height: `${
            isSmallScreen
              ? '350px'
              : isSmallScreenStyle
              ? '290px'
              : isSmallScreenStyleTwo
              ? '550px'
              : '700px'
          }`,
          marginTop: '20px',
          display: 'flex',
          flexDirection: 'row-reverse',
          position: 'relative',
}}>

在 swiper 中我尝试使用以下属性:

1.touchMoveStopPropagation={true}
2.touchStartPreventDefault={false}
3.simulateTouch={假}
4.className =“swiper-no-swiping”-CSS:
.swiper-no-swiping {
指针事件:自动!重要;
}

这些方法没有帮助。
我希望有人能告诉我出了什么问题。
我再说一遍,问题是滚动整个页面而不是幻灯片。

reactjs swiper.js visual-web-developer react-swiper
1个回答
0
投票

我修复了这个问题,对于那些遇到这样问题的人,原因如下:如果你使用 (direction={'vertical'}) swiper 属性,那么由于某种原因,将无法垂直滚动页面用手指(即滑动)移动设备。

© www.soinside.com 2019 - 2024. All rights reserved.