【发布时间】:2015-09-20 11:35:32
【问题描述】:
我使用过 Angular 和 Flask,也使用过路由和转换,但是 React-Router 的工作方式有些令人困惑。
例如来自介绍页面https://github.com/rackt/react-router/blob/master/docs/Introduction.md:
React.render((
<Router>
<Route path="/" component={App}>
<Route path="about" component={About} />
<Route path="inbox" component={Inbox}>
{/* Add the route, nested where we want the UI to nest */}
<Route path="messages/:id" component={Message} />
</Route>
</Route>
</Router>
), document.body)
这段代码嵌套的方式让我很难看到它并告诉你根据我们当前所在的 URL 路径将呈现什么。
例如,“/”部分总是要渲染还是仅在我们处于顶级端点时渲染?
“关于”和“收件箱”是一起呈现还是两者兼而有之?
对不起,如果这对某些人来说非常明显。这让我有点绊倒了太久了,所以我想问问你们。 :)
【问题讨论】:
标签: javascript reactjs react-router url-routing flux