<Switch>
<Route exact={true} path="/" render={()=> <Redirect to="/organization/all" push />}/>
<Route
path="/repository"
children={() => (
<Switch>
<Route exact={true} path="/repository" component={JoinedRepositoryList} />
<Route exact={true} path="/repository/joined" component={JoinedRepositoryList} />
<Route exact={true} path="/repository/joined/create" component={JoinedRepositoryListWithCreateForm} />
<Route exact={true} path="/repository/all" component={AllRepositoryList} />
<Route exact={true} path="/repository/editor" component={RepositoryEditor} />
<Route exact={true} path="/repository/tester" component={RepositoryTester} />
<Route exact={true} path="/repository/checker" component={RepositoryChecker} />
<Route component={NoMatch} />
</Switch>
)}
/>
<Route
path="/organization"
children={() => (
<Switch>
<Route exact={true} path="/organization" component={JoinedOrganizationList} />
<Route exact={true} path="/organization/joined" component={JoinedOrganizationList} />
<Route exact={true} path="/organization/all" component={AllOrganizationList} />
<Route exact={true} path="/organization/repository" component={OrganizationRepositoryList} />
<Route exact={true} path="/organization/repository/editor" component={RepositoryEditor} />
<Route component={NoMatch} />
</Switch>
)}
/>
<Route component={NoMatch} />
<Redirect to="/organization/all" />
</Switch>
使用Redirect组件,Switch最后面需要配置,
<Route exact={true} path="/" render={()=> <Redirect to="/organization/all" push />}/>
|