[Vuejs]-Vue: Limiting users with certain roles have access to certain pages in the router vue-element-admin

0πŸ‘

βœ…

It was not clear to me but there are 2 const areas that the routes can be added to:

constantRoutes
and
asyncRoutes

If you want to use the users roles to determine what they can see your entries has to be in the asyncRoutes

export const asyncRoutes = [
{
    path: '/test1',
    component: Layout,
    redirect: '/',
    name: 'Test',
    alwaysShow: false,
    hidden: true,
    meta: { roles: ['admin'], title: 'Test', icon: 'example' },
    children: [
      {
        path: 'inside',
        props: true,
        name: 'Inside',
        component: () => import('@/views/test/index'),
        meta: { title: 'Inside', icon: 'peoples' },
        hidden: true
      }
    ]
  }
}```

Leave a comment