一个装作异步的代码段
// 获取当前周期 getCurrentCycle(subDepartmentId=this.props.subDepartmentId) { let { dispatch } = this.props calculateApi.currentKaoqinCycle({id:subDepartmentId}).then(res=>{ if (res.data.id) { //console.log(res.data.name); this.setState({ cycleName: res.data.name }) //console.log('CYCLECYCLE',this.state.cycleName); console.log('CYCLECYCLE',res.data.name); }else{ this.setState({ cycleName: '' }) } }) }
用心写代码,不辜负程序员之名。