我有一个几乎没有普通网页的网站和一个包含Google Map的网页.单击地图标记时,地图旁会显示带有标记详细信息的面板.此详细信息具有自己的URL,以便用户可以链接到它:
<Route path="/" component={App}>
<IndexRoute component={Welcome} />
<Route path="map" component={Map}>
{/* Detail is a child component of Map,
it only adds detail panel markup to Map. */}
<Route path="detail/:id" component={Detail} />
</Route>
<Route path="about" component={About} />
</Route>
Run Code Online (Sandbox Code Playgroud)
这很好用.但是,让我们摆脱欢迎页面并在Web根目录上显示Map,以便:
/
渲染 App > Map
组件
/detail/:id
呈现 App > Map > Detail
组件
/about
呈现 App > About
组件
<Route path="/" component={App}>
{/* Map has to be IndexRoute so that it is displayed at root URL. …
Run Code Online (Sandbox Code Playgroud)