react-router里有个withRouter,可以给你的组件注入history啊什么相关路由方法和信息。 import {withRouter} from 'react-router-dom' class MyComponent extends Component { doSth = () => { this.props.history.push('/xxx') } } export default withRouter(MyComponent)
react-router
里有个withRouter
,可以给你的组件注入history啊什么相关路由方法和信息。