this.setState({money: 10000}, () => {
this.setState({
money: this.state.money * 2
});
});
b. 调用 setState 时传入算值函数,该函数在对 state 设值时执行,并带有 previousState, currentProps 参数,可作为算值依据:this.setState({money: 10000});
this.setState(function(previousState, currentProps) {
return {money: previousState * 2};
});
2024 - 快车库 - 我的知识库 重庆启连科技有限公司 渝ICP备16002641号-10
企客连连 表单助手 企服开发 榜单123