Routes.js File

From rbachwiki
Jump to navigation Jump to search
import User from './components/User.vue';
import UserDetail from './components/UserDetail.vue';
import UserEdit from './components/UserEdit.vue';
import UserStart from './components/UserStart.vue';
import Home from './components/Home.vue';

// The "children" keyword is an array which has the subroutes
export const myRoutes = [
    { path: '', component: Home },
    { path: '/user', component: User, children:[
        {path: '', component: UserStart},
        {path: ':id', component: UserDetail, beforeEnter:(to, from, next)=>{
            console.log('inside rout setup');
            next();
        }},
        {path: ':id/edit', component: UserEdit, name: 'userEdit'}

    ] },
    {path: '/redirect-me', redirect: '/user'},
    {path: '*', redirect: '/'}

];

VueJs Routing