is that posible to create Nested Routes more then 2?
i want to create something like this:
+--------------------+
| User |
| +----------------+ |
| | Profile | |
| | +------------+ | |
| | | About | | |
| | | +--------+ | | |
| | | | Detail | | | |
| | | +--------+ | | |
| | +------------+ | |
| +----------------+ |
+--------------------+
so in the web will be like this
link: /localhost/user
web display:
USER
link: localhost/user/profile
web display:
USER
PROFILE
link: localhost/user/profile/about
web display:
USER
PROFILE
ABOUT
link: localhost/user/profile/about/detail
web display:
USER
PROFILE
ABOUT
DETAIL
any example code with jsfiddle will be very appreciated, thanks.
You just have to nest the corresponding routes (obviously you would also need the user's id
parameter):
const router = new VueRouter({
routes: [
{ path: '/user/:id', component: User,
children: [
{
path: 'profile', component: Profile,
children: [
{
path: 'about', component: About,
children: [
{
path: 'details', component: Details,
}
]
}
]
}
]
}
]
})
Same code, but just condensed (maybe it helps to read better):
const router = new VueRouter({
routes: [{
path: '/user/:id', component: User,
children: [{
path: 'profile', component: Profile,
children: [{
path: 'about', component: About,
children: [{
path: 'details', component: Details,
}]
}]
}]
}]
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With