2016-10-06 141 views
0

深層鏈接使用下面的路由配置 -添加使用反應路由器

<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> 

OR

<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 

什麼是鏈接的正確方法?不使用任何處理程序。

回答

0

有點頭腦風暴後,想出了一個解決辦法是什麼我想實現

<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>