路由到嵌套路径v6 reactjs时如何隐藏父组件?
展览元素拥有9个展览的桌子。单击桌子上的展览,我想路由到展览页面(展览1),目前试图通过嵌套路由进行。
在展览中,const i具有<链接到='/doarbients/doartit1'>展览1</link> ...< utlet/>
在单击链接时,exhibit1组件在表下方呈现。
我该如何隐藏父元素(展览)和通往展览1页的路线?
感谢所有的解决方法。
<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>
The Exhibitions element holds a table of 9 exhibitions. On click on an exhibition from the table I want to route to the page of the exhibition (Exhibit1), currently attempting to do so via nested routing.
In the Exhibitions const I have <Link to='/exhibitions/exhibit1'> Exhibit1 </Link> ... <Outlet/>
When clicking on the Link the Exhibit1 component renders under the table.
How can I go about hiding the parent element (Exhibitions), and route to the Exhibit1 page ?
Appreciate all pointers to a workaround.
<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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用一个布局路由,该路由默认情况下呈现
otret
,然后将展览
组件移动到索引路由中。示例:
请参阅:
You can use a layout route that renders an
Outlet
by default and move theExhibitions
component into an index route.Example:
See: