D
D
DmitryWL2018-07-03 22:56:07
Vue.js
DmitryWL, 2018-07-03 22:56:07

Is it possible to propagate meta tags ("guards") to all child components/pages in vue-router?

Good afternoon dear ones. I often found useful solutions for my small developments on your site, but now it's time to ask for advice.
I'm trying to learn vue.js in conjunction with laravel. Essence of the question. Is it possible not to prescribe meta tags in each child element - requireAuth, etc.?

{
      name:'admin',
      path:'/admin',
      component:admin,
       meta: { requiresAuth: true , adminAuth:true , userAuth : false},
       children: [
        {
          name:'test1',
          path:'test1',
          component:test1,
          //  meta: { requiresAuth: true , adminAuth:true , userAuth : false}
        },
        {
          name:'test2',
          path:'test2',
          component:test2,
          meta: { requiresAuth: true , adminAuth:true , userAuth : false}
        },
      ]
    },

Of course, I would like to prescribe in the parent / admin that the role of the Admin is required, and not to produce lines.
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
0
0xD34F, 2018-07-03
@DmitryWL

Is it possible not to prescribe meta tags in each child element - requireAuth, etc.?

Can.
If you were in the habit of reading documentation , you would know that
Well, and further there is an example of code (by the way, just checking the need for authorization).

D
DmitryWL, 2018-07-04
@DmitryWL

0xD34F Thank you very much, I saw it more than once, but I didn’t apply it correctly.
to.matched.some(record => record.meta.requiresAuth instead of to.matched.requiresAuth seems to have solved the issue.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question