implementing-a-simple-middleware-with-vue-router
implementing-a-simple-middleware-with-vue-router copied to clipboard
Update router.js
When using nested routes you probably want to process the parent's middleware too.
This addition loops through the matched parent routes, adds the middleware to an array and then sends it off to your nextFactory. Allowing you to do the following:
{
path: '/',
component: ParentComponent,
meta: {
middleware: [FirstMiddleware]
},
children: [
path: 'child-page',
component: ChildComponent,
meta: {
middleware: [SecondMiddleware]
}
]
}
Thank you for your contribution. But I want to keep this repository in sync with the blog article. And I also want to keep the blog article as simple as possible, because I think the code already is quite complex. So I don't want to add anymore complexity.
I still think this might be useful to some people, could you change this to don't change the code but add comments to the relevant sections of the code for how to change it to work with nested routes?
Otherwise I'll close this. Thanks!