欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

react路由

程序员文章站 2024-02-14 15:01:10
...

主页,登陆,注册

return (

         <Router>

            <Switch>
                
                <Route exact path='/' component={AA} />

                <Route path='/login' component={BB} />

                <Route path='/register' component={CC} />

                <Redirect to='/login'/>

            </Switch>

         </Router>
    );

react router 基础组件

// Routers
<BrowserRouter> and <HashRouter>

// Route Matching
<Route> and <Switch>

component  render  children

// Navigation
<Link> and <NavLink>
  • 参考

react router https://reacttraining.com/react-router/web/guides/basic-components