小编San*_*n X的帖子

如何在路由到嵌套路径v6 ReactJS时隐藏父组件?

展览元素包含 9 个展览的表格。单击表格中的展览后,我想路由到展览页面(Exhibit1),目前正在尝试通过嵌套路由执行此操作。

在展览中我有<Link to='/exhibitions/exhibit1'> Exhibit1 </Link> ... <Outlet/>

单击链接时,Exhibit1 组件将呈现在表格下方。

如何隐藏父元素(Exhibitions)并路由到 Exhibit1 页面?

感谢所有指向解决方法的指针。

<Routes>
 <Route path='/' element={<Home/>}/>
 <Route path='/home' element={<Home/>}/>
 <Route path='/aboutUs' element={<AboutUs/>}/>

 <Route path='/exhibitions' element={<Exhibitions/>}> 
  <Route path='exhibit1' element={<Exhibit1/>}/>
 </Route>

 <Route path='/photographers' element={<Photographers/>}/>
 <Route path='/contact' element={<Contact/>}></Route> 
 <Route path='*' element={<Error/>}> </Route> 
</Routes>
Run Code Online (Sandbox Code Playgroud)

nested-routes reactjs react-router

3
推荐指数
1
解决办法
1294
查看次数

标签 统计

nested-routes ×1

react-router ×1

reactjs ×1