Skip to content

Instantly share code, notes, and snippets.

@ThaddeusJiang
Created July 31, 2018 11:41
Show Gist options
  • Save ThaddeusJiang/5defdeb45d4735210896b63e04f54000 to your computer and use it in GitHub Desktop.
Save ThaddeusJiang/5defdeb45d4735210896b63e04f54000 to your computer and use it in GitHub Desktop.
React Router

URL

// "/:id"
this.props.match.params.id
// "/:r/:g/:b"
this.props.match.params.r
this.props.match.params.g
this.props.match.params.b

Auth

我在 Server 确认

No Match

<Switch>
  <Route path="/" exact component={Home} />
  <Route component={NoMatch} />
</Switch>

按顺序匹配,且只匹配第一个

<Switch>
  <Route ...>
</Switch>

精准匹配 (exact)

<Route path="/" exact component={Home} />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment