Andrew Dean
Andrew Dean

Reputation: 325

vue router going to wrong view

I have set up a vue router using the vue cli and have created a few components & views etc including a modules view with an ID which can be put in but it keeps loading the dashboard view instead of the module view.

no idea why or how it keeps overriding as when I remove the dashboard routing it works fine.

enter image description here

here is my router code and have tried moving things around with no luck.

export default new Router({
    mode: 'history',
    base: process.env.BASE_URL,
    routes: [
        {path: '/', name: 'home', component: Home},
        {path: '/about', name: 'about', component: About},
        {path: '/login', name: 'login', component: Login},
        {path: '/module/:id', name: 'module', component: Module},
        {path: '/dashboard', name: 'dashboard', component: Dashboard, children: [
           { path: '/', component: Main},
           { path: 'modules', component: Modules},
        ]},
   ],
});

extra info

when i switched the order of the imports so dashboard was imported first and module second then it would switch the issue to only going to module view and not dashboard.

Upvotes: 1

Views: 903

Answers (1)

Andrew Dean
Andrew Dean

Reputation: 325

Not sure why this was happening, but after recreating the project using the Vue cli from scratch I stopped having the routing issue.

Upvotes: 1

Related Questions