如图,在axios请求response中对特定状态码做路由跳转,但是react-router v4已经移除了browserHistory,所以跳转失效,除了window.location.href跳转,react有没有比较友好的方式在非组件中跳转路由
如图,在axios请求response中对特定状态码做路由跳转,但是react-router v4已经移除了browserHistory,所以跳转失效,除了window.location.href跳转,react有没有比较友好的方式在非组件中跳转路由
如果事路由之内的组件,用this.props.history.push(''),不是路由之内的组件,从react-router-dom引入withRouter,用它包裹组件,就可以从props中拿到history。withRouter(Component)
import { push } from 'connected-redux-router'
store.dispatch(push('/path'))
1 回答1.7k 阅读✓ 已解决
4 回答1.6k 阅读✓ 已解决
2 回答2.5k 阅读✓ 已解决
1 回答2.6k 阅读✓ 已解决
2 回答1.5k 阅读✓ 已解决
4 回答1.3k 阅读
1 回答1.6k 阅读✓ 已解决