React router v4中去掉了IndexRoute,那么如何设置默认路由呢~
class MainComponent extends Component{
render(){
return <div id="stage">
<Switch>
<Route exact path='/' component={IndexComponent}/>
<Route path='/user' component={UserComponent}/>
</Switch>
</div>
}
}
网上有这样写的:
class MainComponent extends Component{
render(){
return <div id="stage">
<div><IndexComponent></div>
<Switch>
<Route exact path='/' component={IndexComponent}/>
<Route path='/user' component={UserComponent}/>
</Switch>
</div>
}
}
我这样写的时候会出现渲染别个页面组件的时候都会把IndexComponnet这个默认页面组件渲染了出来,麻烦解答一下。
ABOUTYOU
相关分类