简体   繁体   English

"Nuxt.js 默认布局未应用"

[英]Nuxt.js default layout not being applied

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.我是使用 Nuxt.js 的新手,并且遇到了一个问题:当我创建我的项目时,没有按照文档说明自动生成 layouts 文件夹。 I added it manually, but default.vue is not being applied anywhere.我手动添加了它,但 default.vue 没有在任何地方应用。 Here is layouts/default.vue :这是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).我已经尝试过诸如手动将default设置为页面中的布局并在default.vue中手动导入AppHeader组件(尽管这绝对不是问题,因为我放在那里的其他 HTML 也没有呈现)。 Not sure what's going wrong here, scratching my head.不知道这里出了什么问题,挠了挠头。 Using nuxt 2.15.7 .使用nuxt 2.15.7 If there's any additional detail needed please let me know what and I'll gladly provide, thanks.如果需要任何其他详细信息,请告诉我,我很乐意提供,谢谢。

Just define your components folder path in nuxt.config.js只需在 nuxt.config.js 中定义您的组件文件夹路径

eg: components: { dirs: [ '~/shared', '~/shared/atoms', '~/shared/molecules', '~/shared/organisams', ] },例如:组件:{ dirs: [ '~/shared', '~/shared/atoms', '~/shared/molecules', '~/shared/organisams', ] },

Today, I faced the same issue, I just stop the dev command and did "npm run dev" again.今天,我遇到了同样的问题,我只是停止了 dev 命令并再次"npm run dev""npm run dev"

It woked like a charm.它像魅力一样醒来。

I've faced the same problem.我遇到了同样的问题。 Then, just closed the npm run dev command and started again.然后,只需关闭 npm run dev 命令并重新启动。 It worked perfectly for me.它对我来说非常有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM