0
我试图在颜色值更改时更改div
的背景。这里是我的功能,接收颜色值:我如何使用refs来改变ReactJS中的样式类?
ChangeColor(oColor) {
this.props.ChangeColor(oColor);
console.log("Refs: ", this.refs.colorPicker.className);
},
这里是css类
.colorPicker {
padding-right: 25px;
background: #000;
display: inline;
margin-right: 5px;
}
,这里是我的div元素,其背景需要在运行时更新。
<div ref='colorPicker' className={this.GetClass("colorPicker")} />
我不确定关于refs synatx,所以请帮助解决这个问题。谢谢。