JohnCampionJr / vite-plugin-vue-layouts

Vue layout plugin for Vite
MIT License
443 stars 60 forks source link

Not working with nested pages #148

Open Monstermash28425R1 opened 4 months ago

Monstermash28425R1 commented 4 months ago

"I'm having issues with the plugin when working with nested pages. For instance, at the top-level, the plugin works fine, and at the second level too. However, when configuring a third level (pages/auth/login/index.vue), the plugin stops working. Could it be because the URLs are generated as 'childrens'?"

nigiwen commented 2 months ago

May I ask if you have resolved it

WayneBuckhanan commented 2 months ago

I found that explicitly setting a layout for each layer of directory structure resolved my similar issues.

E.g. having a meta layout set for pages/auth/index.vue above would allow pages/auth/login/index.vue to have a non-default meta layout work properly in my projects.

sunpm commented 1 month ago

Yeah, I have that problem too.

Ali-Rooholamini commented 1 week ago

"I found the solution to this problem. I am using a combination of this and the (unplugin-vue-router) package. you need to change the folder structure of the pages to look like this:

"It means creating an index.vue file for each nested folder where you want to have its pages."

Next, you need to specify the layout of the pages in all layers, including layout: default:

pages/tickets/index.vue : (required)

<script setup>
definePage({
    meta: {
        layout: "default",
    },
});
</script>

then, inside pages/tickets/new/index.vue :

<script setup>
definePage({
    meta: {
        layout: "add",
    },
});
</script>