Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add meta in nuxt router?

In vue, we defined meta like this:

const router = new VueRouter({
  routes: [
    {
      path: '/foo',
      component: Foo,
      children: [
        {
          path: 'bar',
          component: Bar,
          // a meta field
          meta: { requiresAuth: true }
        }
      ]
    }
  ]
})

But how do we define meta in nuxt?

like image 590
Damon Avatar asked Oct 13 '18 13:10

Damon


1 Answers

You can use vue-router meta as custom component property. https://github.com/nuxt/nuxt.js/issues/1687#issuecomment-331870619

Simple example https://github.com/nuxt/nuxt.js/tree/2.x/examples/routes-meta

like image 155
shuhei fn Avatar answered Sep 19 '22 03:09

shuhei fn