0👍
it’s easy you can use alias
option of vue-router
:
{
path: "/admin",
name: "admin",
component: Admin,
children: [
{
path: 'event/create', // not repeat path from root
alias: ['/event/create'],
name: 'EventCreate',
component: EventCreate,
props: true
}
// many more routes...
]
}
and one more note never use a path that starts with
/
and repeat the parent path inchildren
it doesn’t work at all it’s verbose, confusing and potentially error-prone
- [Vuejs]-Laravel +Vuejs CORS issue
- [Vuejs]-Updating Nested Objects in Vue using VeeValidate Form issue
0👍
Share route properties with an object
Based on comment by @Estus Flask, here’s one way to have a cleaner routes definition:
Use a object to store shared properites, and use it in relevant routes, reducing duplication. Still, you must still have separate routes for contexts, which makes sense.
Object to hold shared properties:
const MyEventCreateRoute = {
component: EventCreate,
props: true,
// other stuff
}
Routes use the shared properties with spread operator:
// Basic route; not in dashboard:
{
path: '/event/create',
name: 'EventCreate',
...MyEventCreateRoute
}
// Route in admin dashboard; renders inside <NuxtChild>:
{
path: "/admin",
name: "admin",
component: Admin,
children: [
{
path: '/admin/event/create',
name: 'AdminEventCreate',
...MyEventCreateRoute
}
]
}
- [Vuejs]-Vue 3 – input type=file does not read QR code. Which are the alternatives?
- [Vuejs]-Use two submit button in vue js
Source:stackexchange.com