How to use layouts (using named slots)?
I want to use the dashboard-default.vue layout inside all the dashboard pages.
In the dashboard-default.vue, there's 2 named slots for header and content.
How do i use these slots inside the dashboard pages?
I tried this pages/dashboard.vue
and inside the pages/dashboard/index.vue:
This is
pages/dashboard.vue
page:
59 Replies
This is my directory structure:
Yeah i used that
The question is how do i pass title from individual pages to the layout?
So answer on the page
Where u wanna use title?
In script or just on template
My pages are
pages/dashboard/index.vue
, pages/dashboard/settings.vue
I set layout in the parent page pages/dashboard.vue
:
the layout accepts one named slot header
I want to pass this header from the pages inside pages/dashboard/index.vue
, pages/dashboard/settings.vue
so that i can set different titles to the layoutyou confusing layout and pages folders. In nuxt, your layout goes in the layout folder, RTD
Nuxt wont know what to resolve,
pages/dashboard/index.vue
or pages/dashboard.vue
These two create the same route in nuxt's router to www.site.com/dashboard
are you saying you can't have both these files at the same time
pages/dashboard/index.vue
, pages/dashboard.vue
?no you can't what is going to be used for the route?
its working fine for me.
I think both are used for the route
if you want different layouts for the site and for the dashboard you need to put those in the layout folder and choose your layout in the pages component
all i have to do is to include <NuxtPage /> inside the dashboard.vue page
no that's not my original question
do you have a file called
layouts/dashboard-defualt.vue
nuxt probably tries to render default layouts, and for the index.vue it will take priority over dashboard.vueyes I have a layout
layouts/dashboard/default.vue