我有一个 arry :
classesAll:[0:{id:1,title:'test1'},1:{id:2,title:'test2'}]
当我'console.log(this.props.classes.classesAll)'它到控制台时,它不会返回我的数组的异常值。相反,它显示以下内容: undefined [object Object],[object Object]
async componentDidMount() {
await this.props.showAllClasses();
console.log("***", this.props.classes.classesAll)
}
Redux action:
export const showAllClasses = () => {
return async dispatch => {
dispatch(pageLoading(true));
await Api.get(`classes.php`).then(res => {
//this.state.all = res.data;
const classesAll = res.data.data;
state.classesAll = classesAll;
});
await dispatch(onChangeClasessAll(state.classesAll));
dispatch(pageLoading(false));
};
};
export const onChangeClasessAll = classesAll => {
const type = CLASSES_ALL;
return { type , classesAll};
};
守候你守候我
慕田峪9158850
慕容森
相关分类