default.vue layout always runs
See original GitHub issueHi,
I believe I found either a bug – or consider this a feature request. 😃
I have an index.vue
page with a different layout than default.vue
. Let’s say it uses start-layout.vue
. But, all my other pages in /pages
use default.vue
.
When I visit my entry point index.vue
in the browser, I would expect default.vue
’s setup function not to run – alas, it does. That’s a problem for side effects.
Remediation
Avoid having a default.vue
in /layouts
. And configure each page to use a named layout. E.g. not-default.vue
.
Reproduction
Please see here: https://codesandbox.io/s/layout-bug-forked-q02kt. In the console, both layouts fire their respective logs.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:12 (4 by maintainers)
Top Results From Across the Web
layouts\default.vue will be reset after I restart the nuxt.js server
I have found out a problem that whenever I create a new "xxxx. vue" file in the "pages" directory or restarting the nuxt....
Read more >Layouts directory - Nuxt
Default Layout vue file. It will be used for all pages that don't have a layout specified. Make sure to add the...
Read more >Default Theme Config - VuePress
The default theme provides a homepage layout (used on the homepage of this site). To use it, specify home: true plus some other...
Read more >Nuxt layouts for new install & error Component name "default ...
1:1 error Component name "default" should always be multi-word vue/multi-word-component-names. What happens when you use npm run dev with a Nuxt app that ......
Read more >Understanding Vue.js Lifecycle Hooks - DigitalOcean
Creation hooks are the first hooks that run in your component. ... {{ propertyComputed }}</div> </template> <script> export default { data() ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@JohnCampionJr seems this fix is still pending. Is there any problems with the fix above , as issue is quote serious?
The change in this issue didn’t fix it (
const name = ref('')
); also restarted. Nor the fix in https://github.com/JohnCampionJr/vite-plugin-vue-layouts/issues/14I’ve put a log in mounted() for each layout. Starting from default, which is correct 1st time, clicking on a router link which goes to a page using
unauth
layout gives this:Strange that it’s not 100% reproducible.