Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nuxt.js default layout not being applied

Tags:

I'm brand new to using Nuxt.js, and having an issue: When I created my project, the layouts folder wasn't generated automatically as documented. I added it manually, but default.vue is not being applied anywhere. Here is layouts/default.vue:

<template>
  <div>
      <AppHeader/>
      <Nuxt/>
  </div>
</template>

I've tried things such as manually setting default as the layout in pages and manually importing the AppHeader component in default.vue (although this is definitely not the issue as other HTML I put there doesn't get rendered either). Not sure what's going wrong here, scratching my head. Using nuxt 2.15.7. If there's any additional detail needed please let me know what and I'll gladly provide, thanks.

like image 837
Piturnah Avatar asked Aug 06 '21 23:08

Piturnah


People also ask

How do I change the default layout in Nuxt?

You can define a default layout by adding a default. vue file inside the layouts directory. This will be used for all pages that don't have a layout specified. The only thing you need to include in the layout is the <Nuxt /> component which renders the page component.

Is Nuxt faster than Vue?

Nuxt offers better SEO improvement with its server-side rendering feature, faster development with an auto-generic router, public share features, and management with great configuration options and meta tags methods, automatic code splitting with pre-rendered pages — all of this is impossible or extremely complex to ...

Is Nuxt compatible with Vue 3?

Migrating from Vue 2 to Vue 3 using Nuxt BridgeNuxt Bridge is backward compatible, so legacy plugins and modules will still work, while migrating is easy and possible without rewriting the whole application. Your migration using Nuxt Bridge is done!


2 Answers

Today, I faced the same issue, I just stop the dev command and did "npm run dev" again.

It woked like a charm.

like image 73
habib Avatar answered Sep 30 '22 14:09

habib


I also faced this issue today, and it took my like 15 minutes to realize...

I just named my folder layout instead of layouts :')

I'm posting it just in case someone else is as distracted as I am

like image 41
Dony Avatar answered Sep 30 '22 15:09

Dony