简体   繁体   English

为 Bootstrap Carousel 设置 Active class

[英]Set Active class for Bootstrap Carousel

Iam having a bootstrap carousel in which the images are dynamic(from backend api) so i could not set active class for the slides..If i use active className in hardcode, all slides are active at same time.. How to do it dynamically我有一个引导轮播,其中图像是动态的(来自后端 api)所以我无法为幻灯片设置活动 class ..如果我在硬编码中使用活动类名,所有幻灯片同时处于活动状态..如何动态地做到这一点

So far i have tried setting active class using jquery.. I got all the elements inside carousel-inner and then used addClass and removeClass but it did not help me到目前为止,我已经尝试使用 jquery 设置活动的 class .. 我得到了carousel-inner中的所有元素,然后使用了addClass 和 removeClass但它对我没有帮助

sandbox link click here沙箱链接点击这里

Don't use jquery in react project.不要在 React 项目中使用 jquery。 take look on other npm看看其他 npm

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

and if you are using react-bootstrap then check如果您使用的是 react-bootstrap 然后检查

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM