我用的版本
{
"antd": "^5.4.2",
"react": "^18.2.0",
}
示例代码
... ...
const carouselRef = React.createRef();
const App: React.FC = () => {
... ...
const handleChange = (index: string) => {
carouselRef.current.goTo(index);
};
... ...
onChange={() => handleChange(index)}
... ...
return (
<Carousel
effect="fade"
autoplay={false}
dots={false}
ref={carouselRef}
>
... ...
<div>
<h3>... ...</h3>
</div>
... ...
</Carousel>
);
};