react-router v5没有IndexRoute组件,可以直接间Route用于渲染

v5版本的Route可以直接嵌入组件内部,根据path渲染

1
2
3
4
5
6
7
8
9
10
11
12
13
///FrameRoute.tsx
<FrameRoute>
<Route path='/' exact component={Home} />
<Route path='/detail/:id' component={Detail} />
</FrameRoute>
///使用
<HashRouter>
<Route path='/' component={Frame}/>
<HashRouter>
///或者将FrameRoute直接写入Route的render参数
<HashRouter>
<Route path='/' render(()=>{///FrameRoute})/>
<HashRouter>