> 文章列表 > antd走马灯goTo正确使用姿势

antd走马灯goTo正确使用姿势

antd走马灯goTo正确使用姿势

我用的版本

{"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 (   <Carouseleffect="fade"autoplay={false}dots={false}ref={carouselRef}>... ...<div><h3>... ...</h3></div>... ...</Carousel>);
};

就这么简单,官网就是只给你名称,剩下的得自己  ... ...