一个装作异步的代码段

// 获取当前周期
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: ''
})
}
})
}
原文地址:https://www.cnblogs.com/thinkingthigh/p/8484505.html