import {connect} from 'dva'
const mapState=({organization})=>{
const {departmentList} = organization;
return departmentList
}
@connect(mapState)
class OperateComponent extends Component{
先定义一个state
state={
list:[]
};
componentDidMount(){
this.getDepartmentList()
};
getDepartmentList(){
const {dispatch} = this.props;
if(dispatch){
dispatch({type:'organization/oaksDepartmentsEffect'})
.then(()=>{
const {departmentList} = this.props;
let newList = departmentList.length && departmentList.map((item:any)=>{
item.isEdit = false;
return item;
})
this.setState({list:newList})
})
}
};
}
render()中使用this.state.list;
之后直接使用this.getDepartmentList()就可以
Ant design pro常用(10):使用models中数据
最新推荐文章于 2024-06-22 09:43:29 发布