I’m trying to programatically change which page in the /pages directory matches at runtime.
E.g. there are two page components defined in the /pages directory:
/pages/index.vue
/pages/page-wide.vue
Nuxt automatically resolves the url http://<local-url>/page-wide to the page-wide component.
But what if I want to determine the page component at runtime.
E.g:
<local-url>/page-a **needs the default page layout of index.vue**
<local-url>/page-b **needs the page-wide layout**
Is that possible?
I’ve already tried to add a dynamic route via addRoute, e.g.
router.addRoute({
path: '/page-b',
name: 'page-b-route',
component: pageWideComponent,
});
This works for the second navigation, but not for the first (e.g. if I’ll go to the / beforehand and then open the /page-b it works).
Thanks!
Stephan Fletzberger is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.