【发布时间】:2017-07-15 00:17:54
【问题描述】:
此颜色选择器有效,但落后了一步。我一直在使用 React 15.4.2。 在以后的版本中是否有问题要修复? 如果是我的错,请问如何掌握“待定状态条件”? 笔http://codepen.io/462960/pen/qrBLje 代码:
let Input = React.createClass({
getInitialState(){
return {
today_color: "#E5D380"
};
},
colorChange(e){
this.setState({
today_color: e.target.value
})
document.querySelector('html').style.setProperty('--base', this.state.today_color);
},
render(){
return (<div>
<input className="today_color" onChange={this.colorChange} type="color" defaultValue={this.state.today_color}/>
</div>)
}
})
【问题讨论】: