問(wèn)題描述:react antd Form 切換Table分頁(yè)后Table內(nèi)Input數(shù)據(jù)丟失問(wèn)題處理
處理思路:在合適的時(shí)候更新數(shù)據(jù)源dataSource,例如切換分頁(yè)前或編輯完成后,使dataSource保持在最新?tīng)顟B(tài)。
相關(guān)代碼
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
});
};
參考:
react antd Form 切換Table分頁(yè)后Table內(nèi)Input數(shù)據(jù)丟失問(wèn)題處理 相關(guān)源碼