例如,
state = {
data: {}
}
如何将新的嵌套字段添加到对象中?我无法设置该字段,因为有错误Cannot read property 'date' of undefined
const reducer = produce((draft, action) => {
switch (action.type) {
case 'ACTION_SUCCESS':
draft.data.children.date = action.response;
}
});
结果我想要:
data: {
children: {
data: 'date'
}
}
}