反应路由器:子路由器不工作

时间:2016-01-27 08:34:10

标签: react-router

我尝试使用react路由器(代码下面)定义子路径,但子路由不起作用,并且它不会返回任何错误消息。

<Router>
    <Route path="/" component={Main} >
        <IndexRoute component={Dashboard} />
        <Route path="create" component={UserList} />
        <Route path="user/create" component={CreateUser} />
        <Route path="createGroup" component={CreateGroup} />
        <Route path="groups" component={GroupList} />
        <Route path="premission" component={PremissionList}>
            <Route path="create" component={CreatePremission} />
        </Route>
    </Route>
</Router>

我需要将premission/create路由到create premission组件。

1 个答案:

答案 0 :(得分:0)

要执行多种类型的深层/嵌套路由,您需要遵循以下方法:

<Router>
    <Route path="/" component={Main} >
        <IndexRoute component={Dashboard} />
        <Route path="create" component={UserList} />
        <Route path="user/create" component={CreateUser} />
        <Route path="createGroup" component={CreateGroup} />
        <Route path="groups" component={GroupList} />
    </Route>
    <Route path="/premission" component={PremissionList}>
        <Route path="create" component={CreatePremission} />
    </Route>
</Router>