2015-09-27 101 views
4

我在想下面例子中IndexRouteDefaultRoute有什麼區別?據我瞭解,這兩種情況下Home將呈現,對吧?反應路由器:IndexRoute與DefaultRoute

<Route path="/" handler={App}> 
    <IndexRoute handler={Home}/> 
    <Route path="about" handler={About}/> 
</Route> 

<Route path="/" handler={App}> 
    <DefaultRoute handler={Home}/> 
    <Route path="about" handler={About}/> 
</Route> 

回答

8

DefaultRoute消失作爲反應路由器V1.0的。改爲引入IndexRoute

從文檔:

// v0.13.x 
// with this route config 
<Route path="/" handler={App}> 
    <DefaultRoute name="home" handler={Home}/> 
    <Route name="about" handler={About}/> 
</Route> 

// v1.0 
<Route path="/" component={App}> 
    <IndexRoute component={Home}/> 
    <Route path="about" component={About}/> 
</Route> 

更多的upgrade guide.