react-router4.0 js如何跳转,如何地址栏传递?key=value的参数,在新页面如何获取

react-router4.0 js如何跳转,如何地址栏传递?key=value的参数,在新页面如何获取

阅读 2.4k
2 个回答

react-router里有个withRouter,可以给你的组件注入history啊什么相关路由方法和信息。

import {withRouter} from 'react-router-dom'

class MyComponent extends Component {
    doSth = () => {
        this.props.history.push('/xxx')
    }
}
export default withRouter(MyComponent)

用的2可以this.props.location.query.key
不知道4有没有

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题