📜  更新嵌套属性 js - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:25.881000             🧑  作者: Mango

代码示例1
onChange(e) { 
  const { user } = { ...this.state };
  const currentState = user;
  const { name, value } = e.target;
  currentState[name] = value;

  this.setState({ user: currentState });
}