reactjs-是否可以有非嵌套路由
我在和你玩。在所有示例中,管线总是嵌套的,例如reactjs-是否可以有非嵌套路由,reactjs,react-router,Reactjs,React Router,我在和你玩。在所有示例中,管线总是嵌套的,例如 <Route path="/" handler={App} > <Route name="about" handler={About} /> <Route name="contact" handler={Contact} /> </Route> 是否可以有简单的非嵌套路由,如下图所示 <Route path="/" handler={App} /> <Ro
<Route path="/" handler={App} >
<Route name="about" handler={About} />
<Route name="contact" handler={Contact} />
</Route>
是否可以有简单的非嵌套路由,如下图所示
<Route path="/" handler={App} />
<Route name="about" handler={About} />
<Route name="contact" handler={Contact} />
更新:
var routes = (
<Route name="root" handler={Root}>
<Route path="/" handler={Home} />
<Route path="/home" handler={Home} />
<Route path="/about" handler={About} />
<Route path="/projects" handler={Projects} />
<Route path="/contact" handler={Contact} />
</Route>
);
var路由=(
);
奇怪的问题,在按照下面的答案进行更新后<代码>名称不再工作,只有路径工作?我必须更新我的路线。有什么想法吗 这似乎是不可能的。但我用了一个技巧来模仿这种行为:
var Routes = (
<Route name="root" handler={Root}>
<Route name="checkout" path="/checkout/:step" handler={Checkout}/>
<Route name="application" path="/" handler={Application}>
<DefaultRoute handler={Promo}/>
<Route name="agreement" handler={Agreement}/>
<Route name="policy" handler={Policy}/>
<Route name="how-it-works" handler={Brief}/>
<Route name="login" handler={Login}/>
<Route name="faq" handler={Faq}/>
...
<NotFoundRoute handler={NotFound}/>
</Route>
<NotFoundRoute handler={NotFound}/>
</Route>
);
var路由=(
...
);
其中,Root
只是一个基本的html页面,带有一个body标记,内容由路由处理程序呈现
在这里,我需要一个具有不同页面布局的签出页面,但与协议或登录页面位于相同的路径段级别 此示例来自正在工作的项目。处理的路由将是:/、/checkout/*、/agreement等。代码大约在2个月前编写。