Router

Router Configuration

Reference: https://router.vuejs.org/

Configure routers in src/router.js

src/router.js
routes: [
{
path: '/',
redirect: 'dashboard/alpha',
component: MainLayout,
meta: {
authRequired: true,
hidden: true,
},
children: [
// Dashboards
{
path: '/dashboard/alpha',
meta: {
title: 'Dashboard Alpha',
},
component: () => import('./views/dashboard/alpha'),
},
...
],
},
]

History Mode (removing /#/ hash from Url)

Don't forget configure rewrites on your server. Read more: https://router.vuejs.org/guide/essentials/history-mode.html

Uncomment mode: 'history' in src/router.js

src/router.js
const router = new Router({
base: process.env.BASE_URL,
// mode: 'history',
scrollBehavior() {
return { x: 0, y: 0 }
},
...
}

Routes Guard

See src/router.js for router.beforeEach method. On every route change the app checked authorization and if user is not authorized will redirect him to /user/login route.

Details: https://router.vuejs.org/guide/advanced/navigation-guards.html