Answer the question
In order to leave comments, you need to log in
How to "disable" the behavior of the layouts folder in nuxt in order to prescribe layout in router.js?
In the project I use the @nuxt/router package/module ( https://github.com/nuxt-community/router-module#readme ). It allows you to use router.js like you would in a regular vue app. However, I cannot set the layout of the component in the router.
In the layouts folder, I create the auth.vue component. In the pages folder, I create the login and register components.
The expected result (the code is for an example and not from the project):
const router = new VueRouter({
routes: [
{
path: '/auth', component: Auth,
children: [
{ path: 'login', component: AuthLogin },
{ path: 'register', component: AuthRegister }
]
}
]
})
Every file (top-level) in the layouts directory will create a custom layout accessible with the layout property in the page components.
export default {
layout: 'auth',
// OR
layout (context) {
return 'auth'
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question