this.state={
param: 1
}
func1 = () => {
this.setState({param: param+1})
}
func2 = async () => {
await this.func1() // 没有await的话,后面console.log(param)输出1
const { param } = this.state
console.log(param) // 输出2
}
react:async和await控制setState同步更新
最新推荐文章于 2022-08-22 19:40:42 发布