https://reacttraining.com/react-router/web/guides/quick-start

示例

url: https://reacttraining.com/react-router/web/example/no-match

const {
  HashRouter,
  Route,
  Switch,
  Redirect,
} = window.ReactRouterDOM

return (
  <HashRouter>
    <Switch>
      <Route exact path="/">
        {`<Home />`}
      </Route>
      <Route path="/old-match"> {/* 重定向 */}
        <Redirect to="/will-match" />
      </Route>
      <Route path="/will-match">
        {`<WillMatch />`}
      </Route>
      <Route path="*"> {/* 404 */}
        {`<NoMatch />`}
      </Route>
    </Switch>
  </HashRouter>
)

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-08
  • 2021-06-20
  • 2021-06-19
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-26
  • 2022-12-23
相关资源
相似解决方案