I am migrating my vue application vue 2 to vue 3 by following vue migration official documentation. I have updated vue-router package. After updating router.js if i am running the application in my local by default it is routing to 404 page not found component.
Previously, It was routing to overview page(http://localhost:8080/overview). Now this url is routing to page not found. Here is my router.js
router.js
/* [IMPORT] Library */
import { createRouter, createWebHistory } from 'vue-router';
/* [IMPORT] Common module */
import store from '~/common/store';
/* [IMPORT] modules */
import devModule from '~/module/devModule';
import pageNotFoundPage from '~/page/common/pageNotFound';
/* [IMPORT][PAGE] OverView */
import overviewPage from '~/page/overview/overviewPage';
const routes = [
{ path: '/' , redirect: '/dev'},
{ path: '/dev', component: devModule, children: [
/* Default routing*/
{ path: '', redirect: 'overview/overview'},
/* OVERVIEW */
{ path: 'overview', redirect: 'overview/overview'},
{ path: 'overview/overview' , component: overviewPage}
]},
/* [404] anything else... */
{ path: '/:catchAll(.*)' , component: pageNotFoundPage },
];
export const router = createRouter({ history: createWebHistory(), routes });
/* [intercepter] */
router.beforeEach(function(to, from, next) {
// 1. Update current URL :: for store
store.commit('moveMenu',to.path);
// x. go to next menu
next();
});
export default router;
Why it is not routing to overview page after migration? Any suggestion or guide will be helpful related to this.
You should concatenate the child route path with parent one like :
http://localhost:8080/dev/overview
for more details check nested-routes section in official docs