react 的className动态修改

时间:2019-06-05 11:55:52   收藏:0   阅读:331

https://blog.csdn.net/suwyer/article/details/81481507(copy)

<div style={{display: (index===this.state.currentIndex) ? "block" : "none"}}>此标签是否隐藏</div>
<div style={{display: (index===this.state.currentIndex) ? "block" : "none", color:"red"}}>此标签是否隐藏</div>
<div className={index===this.state.currentIndex?"active":null}>此标签是否选中</div>
<div className={`container tab ${index===this.state.currentIndex?"active":null}`}>此标签是否选中</div>

最好一种推荐使用

原文:https://www.cnblogs.com/dianzan/p/10978572.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!