为 Bootstrap 轮播设置活动 class

Set Active class for Bootstrap Carousel

我有一个 bootstrap 旋转木马,其中图像是动态的(来自后端 api)所以我无法为幻灯片设置活动 class ..如果我使用活动 class硬编码名称,所有幻灯片同时处于活动状态.. 如何动态地做到这一点

到目前为止,我已尝试使用 jquery 设置活动 class。我在 carousel-inner 中获取了所有元素,然后使用 addClass 和 removeClass 但它对我没有帮助

sandbox link click here

不要在 React 项目中使用 jquery。查看其他 npm

https://www.npmjs.com/package/react-responsive-carousel

如果您使用的是 react-bootstrap,请检查

https://react-bootstrap.github.io/components/carousel/