使用以下路由配置-
<Router history={hashHistory}>
<Route name="Home" path="/" component={BaseLayout}>
<Route name="Gateways" path="/gateways" component={DashboardLayout}>
<Route name="Login" path="/login" component={Login}/>
<Route name=":id" path="/gateways/:id">
<IndexRoute name="Dashboard" component={ViewGateWay}/>
<Route name="Access Points" path="/accesspoints" component={AccessPoints}>
<Route name=":id" path="/:id" component={ViewAccessPoint}/>
</Route>
<Route name="Devices" path="/devices" component={Devices}>
<Route name=":id" path="/:id" component={ViewDevice}/>
</Route>
</Route>
<IndexRoute component={Gateways} />
</Route>
<IndexRedirect to="Login" />
</Route>
</Router>在用于面包屑的路线中使用name。有一个侧边菜单,其中有链接到/gateways/:id,/gateways/:id/devices,/gateways/:id/accesspoints,此外,最后两个有链接到单独的设备和接入点使用Link作为/gateways/:id/devices/:id和/gateways/:id/accesspoints/:id。当我在侧边菜单中给出链接时
<Link to="/gateways/${this.props.params.id}/accesspoints">Access Points</Link>或
<Link to="/accesspoints">Access Points</Link>我没有得到正确的页面。设备链接也是如此。我正在尝试实现下面的API与面包屑。
home/gateways/GW_ID1/dashboard
home/gateways/GW_ID1/accesspoints
home/gateways/GW_ID1/accesspoints/GW_AP1
home/gateways/GW_ID1/devices
home/gateways/GW_ID1/devices/GW_DV1链接的正确方法是什么?不使用任何处理程序。
发布于 2016-10-07 16:54:13
集思广益之后,我提出了一个我想要实现的解决方案
<Route name=":gid" path="/gateways/:gid">
<Route name="Dashboard" path="/gateways/:gid/dashboard" component={ViewGateWay}/>
<Route name="Access Points" path="/gateways/:gid/accesspoints" component={AccessPoints}>
<Route name=":apid" path="/gateways/:gid/accesspoints/:apid" component={ViewAccessPoint}/>
</Route>
<Route name="Devices" path="/gateways/:gid/devices" component={Devices}>
<Route name=":did" path="/gateways/:gid/devices/:did" component={ViewDevice}/>
</Route>
</Route>https://stackoverflow.com/questions/39896114
复制相似问题