【发布时间】:2019-06-07 13:32:33
【问题描述】:
现在带有背景的示例文本将变为红色。但我想要类 rightElement: 在拥有border-top: color 之后。它应该取自 const。我不知道该怎么做
const color = "red";
<div className='rightElement' style={{backgroundColor: color} >Example </div>
rightElement:after
{
border-top :color ( From const color )
}
【问题讨论】:
-
要求 i:我需要从配置文件中传递颜色,示例颜色:红色,1. 在 div rightElement 中,我使用 this.props.color 获取配置值颜色:红色。但我需要className rightElement:after (它是一个伪元素)也是(我需要来自 props )。它可以使用 react.js 来做到这一点
标签: javascript reactjs