lesson 184: route meta

This commit is contained in:
Andreas Zweili 2021-05-04 16:35:48 +02:00
parent e6545dd015
commit 904fe565f5
1 changed files with 7 additions and 2 deletions

View File

@ -13,6 +13,9 @@ const router = createRouter({
{ {
name: 'teams', name: 'teams',
path: '/teams', path: '/teams',
meta: {
needsAuth: true
},
component: TeamsList, component: TeamsList,
children: [ children: [
{ {
@ -34,8 +37,10 @@ const router = createRouter({
} }
}); });
router.beforeEach(function(to, from, next) { router.beforeEach(function(to, _2, next) {
console.log(to, from); if (to.meta.needsAuth) {
console.log('Needs authentication.');
}
// if (to.name === 'team-members') { // if (to.name === 'team-members') {
// next(); // next();
// } else { // } else {