gpt4 book ai didi

javascript - React SwiperJs 自动播放不会使刷卡器自动刷卡

转载 作者:行者123 更新时间:2023-12-05 00:24:39 26 4
gpt4 key购买 nike

我在 React 中使用这个 swiper:
https://swiperjs.com/react/
我试图让它“自动播放”,但它不会自动滑动。
这是我尝试过的:

// https://swiperjs.com/get-started/
import React from 'react';
import { Swiper, SwiperSlide } from 'swiper/react';
import { makeStyles } from '@material-ui/core/styles';

const useStyles = makeStyles({
SwiperStyle: {
backgroundColor: '#f5f5f5',
height: '58px',
width: '100%',
},
});

export default function TextInfoSlider(props) {
const classes = useStyles();

return (
<div>

<Swiper
loop={true}
autoplay={{
delay: 500,
disableOnInteraction: false
}}
>

<SwiperSlide>Slide 1</SwiperSlide>
<SwiperSlide>Slide 2</SwiperSlide>
<SwiperSlide>Slide 3</SwiperSlide>
<SwiperSlide>Slide 4</SwiperSlide>

</Swiper>

<style jsx global>{`
.swiper-container {
background-color: #f5f5f5;
}
`}</style>
</div>
)
}
我也尝试在自动播放上使用 bool 值,但它也不起作用:
        <Swiper
loop={true}
autoplay={true}
}}
>

最佳答案

By default Swiper React uses core version of Swiper (without any additional components). If you want to use Navitation, Pagination and other components, you have to install them first你好像没有安装Autoplay零件。


import SwiperCore, { Autoplay } from 'swiper';
...
SwiperCore.use([Autoplay]);

关于javascript - React SwiperJs 自动播放不会使刷卡器自动刷卡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63052586/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com