我的action如下
export function PostMoviesIn(url){
return function(dispatch){
dispatch(StartRquest(url));
console.log(1)
return axios.get('/api'+url).then((res)=>{
dispatch(EndRequest(url, res['subjects']));
}
)
}
}
export function PostMoviesTop(url){
return function(dispatch){
dispatch(StartRquest(url));
return axios.get('/api'+url)
.then((res)=>{
dispatch(EndRequest(url, res['subjects']));
}
)
}
}
connect的配置如下
const mapDispatchToProps = (dispatch) => {
return {
getIn: () => dispatch(PostMoviesIn('/v2/movie/in_theaters')),
getTop: () => dispatch(PostMoviesTop('/v2/movie/in_theaters'))
}
}
通过provider将store传到子组件,我在子组件中调用如下
getInTh(){
this.props.getTop()
}
发现根本执行不到异步action的then中,不会发出请求,请大佬帮忙解决
你可以检查下是不是请求出错了,所有没有走到.then()方法里。