简体   繁体   English

ReactJS中如何设置嵌套路由和嵌套组件

[英]How to setup nested routing and nested components in ReactJS

I am trying to implement a Dashboard (Admin-UI) using ReactJS, but the problem is I can't set up the nested routing and components for that.我正在尝试使用 ReactJS 实现仪表板 (Admin-UI),但问题是我无法为此设置嵌套路由和组件。 I want to load the components on the same page (Home) without going to a new page, as well as loading components based on the SideNav.我想在不转到新页面的情况下在同一页面(主页)加载组件,以及基于 SideNav 加载组件。 How to do that?怎么做? Admin-UI管理界面

A very high level way to achieve this to be:实现这一目标的一种非常高级的方法是:

have a home component, which contains 2 components, side nav and display screen.有一个主页组件,其中包含 2 个组件,侧面导航和显示屏。

declare all the controlling states in the home component and pass them as props for the 2 child components.在 home 组件中声明所有控制状态,并将它们作为 props 传递给 2 个子组件。 Use side nav to change the controlling state in home component and use those states and some conditional logic to render the components inside display screen.使用侧边导航更改主组件中的控制 state 并使用这些状态和一些条件逻辑在显示屏内呈现组件。

Also, please add a code snippet in future.另外,请在以后添加代码片段。 People will be able to help you better.人们将能够更好地帮助你。

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

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