-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change default layout programmatically #14658
Comments
Great idea, I'll submit a function of this later to help with changes |
If you want the layout updated on SSR, you will need to change it before the layout starts rendering, which means it needs to be changed within a plugin or a middleware rather than within a page. (By the time a page renders on server, the layout has already been rendered 'around' it, so it's too late to change it.) On client, things are reactive so you don't need to worry so much about order. It might be worth adding a very brief note about this to the documentation, though we do document that setting |
I've tried setting the
|
Yes, sorry for the misleading tip. Middleware is where you'd want to be if you're doing it on server. And note that you will have to ensure that you are setting layout on client too to ensure the page hydrates. You could use See https://stackblitz.com/edit/github-jcup64 for an example. |
This indeed works! Thanks a lot for clearing up the confusion and for providing a solution. |
This is now added to docs (and |
Describe the feature
In Nuxt 2 there is a very nice method called
$nuxt.setLayout('layout2')
. Sadly in Nuxt 3, this functionality is nowhere to be found.The following method works but you cannot access any variables in this function. So you won't be able to set it dynamically.
And this option won't be executed on SSR but only when the page is loaded. The page source won't show anything about the layout.
So I'm going to assume this functionality isn't in the build yet or it isn't in the documentation.
Additional information
Final checks
The text was updated successfully, but these errors were encountered: