state连续调用的问题
onChange = (k: any, v: any) => {console.log('v', v);
const form = _.cloneDeep(this.state.form);
_.set(form, k, v);
this.setState({
form
});
};onChange();onChange();<br><br>因为 setState 是异步的连续调用两次肯定是有问题的
onChange = async(k: any, v: any) => {
console.log('v', v);
const form = _.cloneDeep(this.state.form);
_.set(form, k, v);
await this.setState({
form
});
};
await onChange();await onChange();
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!
页:
[1]