this.state.style:{
width:
height:
color
}
//修改属性
this.setState({style:{}})
Now I want to add an attribute to it through setState. Can I only add one attribute and keep the other attributes with their original values?
漂亮男人2017-05-19 10:35:56
When using Object.assign()
, be careful not to return the original object, but a new object:
this.setState(Object.assign({}, this.state.style, {width: 666}))