Object.assign({})
cosnt data = Object.assign({}, this.state[status.age], {id: status.key + 1})
this.setState({
[status.age]: data
}, () => {
this.list(status.age);
})
list = (key) => {
console.log(this.state[key])
}
注意 :[status.age] 这个是一个对象
这样不管字符串还是对象都可以拿到覆盖的信息了