const routes = [{
path: '/',
element: <Layout/>,
children: [
{
path: '/home',
element: <Home/>,
}
]
}]
I hava two components, Home
and Layout
. I would like to redirect my url for eg to '/home' when I only write /
, but here is a problem: Layout
can't bind element.
{
path: '/',
element: <Navigate to="/home"/>
}
or use index router, but I can't set path = '/home', Layout
and Home
use same url /
, I don't want this.
I use React router version "react-router-dom": "^6.3.0"
, So how can I set default router?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.