答案在下面:
data[index][name]=value
点击一个更新一次
index 下标
name对应的字段
value就是值
感觉这个靠谱些,具体如何实现呢
<Select className='table-user-name-input'
onChange={this.onChange}
labelInValue>
{
this.state.entityNameOptions_kLevelExpand_1.map(item => (
<Option key={item.value} title={item.text}>{ item.text }</Option>)
}
</Select>
源码地址:
百度网盘
页面地址:srcpagesBusinessModelcomponentsConnectForm.tsx
save = e => {
const { record, handleSave } = this.props;
this.form.validateFields((error, values) => {
if (error && error[e.currentTarget.id]) {
return;
}
handleSave({ ...record, ...values });
});
};
handleSave = row => {
const newData = [...this.state.dataSource];
const index = newData.findIndex(item => row.key === item.key);
const item = newData[index];
newData.splice(index, 1, {
...item,
...row
});
this.setState({ dataSource: newData });
};
如果我来实现,我会加一层闭包: