lesson 184: route meta
This commit is contained in:
parent
e6545dd015
commit
904fe565f5
|
@ -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 {
|
||||||
|
|
Reference in New Issue