Swiper 自动播放在 React.js 中不起作用

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

我在 react.js 中有 Swiper 滑块

<Swiper
    modules={[EffectFade, Pagination]} 
    effect="fade" 
    slidesPerView={1} 
    loop={true} 
    autoplay={{ delay: 4000 }}
    pagination={{
     clickable: true,
     type: 'bullets', // set pagination type to 'bullets'
     dynamicBullets: true // create dynamic number of dots based on number of slides
   }}>

但它不起作用,我看了一些视频,它完全相同但不起作用,我还尝试将自动播放设置为默认 true

autoplay={true}

但无论如何它都不起作用。有什么建议吗?

reactjs swiper.js autoplay react-swiper
1个回答
0
投票

对于任何遇到同样问题的人。我进口了这些


import SwiperCore from 'swiper'
import { Autoplay } from 'swiper';

这就完成了

SwiperCore.use([Autoplay]);
© www.soinside.com 2019 - 2024. All rights reserved.