powerdong / myProblems

我用到了,你可能用到
0 stars 1 forks source link

React 修改 state中对象 #34

Open powerdong opened 4 years ago

powerdong commented 4 years ago
state={
 datavalue:{
      name:'',
      memo:''
     },
 }

设置 state 值

SetName=(e)=>{
      let val=e.target.value;
      let data = Object.assign({}, this.state.datavalue, { name: val })
      this.setState({
        datavalue: data
      })
}