action中定義了一個請求方法:export function add(body) { return dispatch => {
api.add(body)
.then(res => { if (res.data === 200) { // browserHistory.push('/index')
//this.props.history.push('/index')
}
dispatch({ type: 'ADD_LIST', payload: res.data
});
});
}
}
把這個add方法引入頁面中,在頁面的點擊事件直接調用:
handleSubmit = () => { this.props.add()
}在add方法中, 接口返回200 后,如何讓路由跳轉到 index 頁面, if里面的2種寫法都會報錯, 達不到效果, 請問怎么操作,能達到效果呢? 謝謝大家!
判斷后端返回值正確,路由如何自動跳轉
ibeautiful
2019-01-30 09:30:42