You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If it can be realized by existing "beforeEach" hook, Is it really necessary? Yes. It's a beautiful and DRY way to check user authentification or page access rights, logging or A/B tests. Also, it isn't breaking existing code.
What does the proposed API look like?
Example from the article. Maybe the object "meta" isn't necessary. It should be discussed.
importVuefrom'vue';importRouterfrom'vue-router';importauthfrom'./middleware/auth';importlogfrom'./middleware/log';importHomefrom'./views/Home.vue';importLoginfrom'./views/Login.vue';importUserfrom'./views/User.vue';Vue.use(Router);constrouter=newRouter({routes: [{path: '/',name: 'home',component: Home,meta: {middleware: log,},},{path: '/login',name: 'login',component: Login,meta: {middleware: log,},},{path: '/user',name: 'user',component: User,meta: {// Hint: try to switch those two around to see// how this affects execution of the callbacks.middleware: [auth,log],},},],mode: 'history',});exportdefaultrouter;
The text was updated successfully, but these errors were encountered:
What problem does this feature solve?
Simple middleware out of the box. The idea and realization were shown in this article https://markus.oberlehner.net/blog/implementing-a-simple-middleware-with-vue-router/
And I think it's really good solutions for router middleware.
If it can be realized by existing "beforeEach" hook, Is it really necessary? Yes. It's a beautiful and DRY way to check user authentification or page access rights, logging or A/B tests. Also, it isn't breaking existing code.
What does the proposed API look like?
Example from the article. Maybe the object "meta" isn't necessary. It should be discussed.
The text was updated successfully, but these errors were encountered: