We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
引用 withRouter 导出组件时使用
import { withRouter } from 'react-router-dom'; class Header extends React.Component { } export default withRouter(Header);
import { NavLink } from "react-router-dom"; <NavLink to="/modify">修改密码</NavLink>
this.props.history.push({ pathname: 'login', query: { id: 3231, name: 3231 } }) this.props.history.push('modify')
this.props.match.query.id // 3231 this.props.match.params.name // 3231
父组件:
state = { collapsed: false, }; render() { const { collapsed } = this.state; return ( <Slider collapsed={collapsed}/> ) }
子组件:
componentDidMount(){ // console.log(this.props) const { pathname } = this.props.location if( pathname ) { this.setState({ selectedKeys:this.props.location.pathname }) } }
console.log(this.props)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
一、跳转
1、history.push 跳转
2、NavLink跳转
二、传值
1、路由传值 query/params
2、路由传值获取参数
3、props传值
父组件:
子组件:
The text was updated successfully, but these errors were encountered: