Skip to content
New issue

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

72.React 路由传参跳转 #72

Open
wqjiao opened this issue Feb 24, 2021 · 0 comments
Open

72.React 路由传参跳转 #72

wqjiao opened this issue Feb 24, 2021 · 0 comments

Comments

@wqjiao
Copy link
Owner

wqjiao commented Feb 24, 2021

1、params

  • 参数采用动态路由
<Route path="detail:id" component={Detail} />
  • js跳转
this.props.history.push('detail/1');
  • 接收参数
this.props.match.params.id;

2、query

  • js 跳转
this.props.history.push('detail?id=1');

或者

this.props.history.push({
  pathname: 'detail',
  query: {
    id: 1
  }
});
  • 接收参数
this.props.match.query.id;

3、state

  • js 跳转
this.props.history.push({
  pathname: 'detail',
  state: {
    id: 1
  }
});
  • 接收参数
this.props.location.state;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant