简体   繁体   English

React Router 5 - 如何为没有标题和侧边导航栏的特定页面定义路由

[英]React Router 5 - How to define the route for specific page without header and side navigation bar

I am building a react application using react-router 5 and here is the screen flow in the attachment.我正在使用 react-router 5 构建一个 react 应用程序,这里是附件中的屏幕流程。 I am quite confused to achieve the route as per the UI.我很困惑按照用户界面实现路线。

Basically, the application has 4 screen which starts with Login, gets into Student List( List of items ), Student Info( Particular student info in limited ) and Student Info( Particular student info in detailed )基本上,该应用程序有 4 个屏幕,从登录开始,进入学生列表(项目列表)、学生信息(有限的特定学生信息)和学生信息(详细的特定学生信息

- Login ('/') --> No header and side nav bar
 - Student List ('/students')--> Student Info('/student/01') - --> With header and side nav bar
 - Student Detailed Info ('/detail')- --> Without header and side nav bar(but not a modal window)

Screen Flow:屏幕流程: 在此处输入图片说明

You can: 1 -你可以: 1 -

<Route path="students">
// Wrap the routes/pages with header and sidebar
</Route>
<Route path="detail">
// Wrap the routes/pages without header and sidebar
</Route>

2 - on header/sidebar components, detect the current route and skip these components rendering. 2 - 在标题/侧边栏组件上,检测当前路由并跳过这些组件渲染。

You can achieve it by structure of you routes...您可以通过路线结构来实现它...

<Route exact path="\">
 login screen
</Route>
<Route>
 <Header />
 <sidebar />
 <Switch>
  <Route path="students" />
  <Route path="info" />
  ...
 </Switch>
</Route>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM