用Switch
<BrowserRouter>
<Switch>
<Route path="/home"
render={() => (
<Switch>
<Route path="/a/a1" />
<Route path="/b/b1" />
<Redirect to="/c/c1" />
</Switch>
)}
/>
<Route path="/404" component={No} />
<Route path="/login" component={Login} />
</Switch>
</BrowserRouter>
上面大概意思就是Switch会去精确匹配,找不到的话,会处理Redirect的逻辑