0👍
✅
You have two options…
- Wait till all your imports resolve before creating your router. This would involve being able to postpone the creation of your root Vue instance
- Create your router using lazy-loaded components.
I would recommend option #2
new VueRouter({
mode: 'history',
routes: data.map(page => { // data as defined in your GetAllPages function
const pageTitle = page.title.rendered.toLowerCase()
return {
path: `/${pageTitle}`,
name: pageTitle,
component: () => import(`../pages/${pageTitle}.js`)
}
})
});
Source:stackexchange.com