question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

default.vue layout always runs

See original GitHub issue

Hi,

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:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
husaytcommented, Apr 22, 2021

@JohnCampionJr seems this fix is still pending. Is there any problems with the fix above , as issue is quote serious?

0reactions
mariusacommented, Apr 30, 2021

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/14

I’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:

default layout mounted
unauth layout mounted
default layout mounted

Strange that it’s not 100% reproducible.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found