开发者问题收集

Nuxt3 未导入组件

2022-03-18
2019

我按照基本教程来启动一个 nuxt3 项目:

cd /myfolder
yarn init -y
yarn add --dev nuxt3
yarn nuxi create nuxt3-app
cd nuxt3-app
yarn install
yarn dev -o

然后我删除 app.vue

我创建了目录:

mkdir components pages layouts

以及文件:

touch components/Header.vue
touch pages/index.vue
touch layouts/default.vue
// components/Header.vue
<template>
  <div>
    HEADER
  </div>
</template>
// pages/index.vue
<template>
  <div>
    INDEX
  </div>
</template>
// layouts/default.vue
<template>
  <div>
    <Header />
    <slot />
  </div>
</template>

但是 Header 组件未包含在内。如果我连接到 http://localhost:3000 ,我只会看到单词 INDEX

我哪里错了?

我已经按照官方文档中的教程进行了操作:

https://v3.nuxtjs.org/getting-started/installation

https://v3.nuxtjs.org/docs/directory-structure/components/

Nuxt project info:                                                                                                                                                                                       

------------------------------
- Operating System: `Linux`
- Node Version:     `v16.13.1`
- Nuxt Version:     `3.0.0-27459267.f69126e`
- Package Manager:  `[email protected]`
- Builder:          `vite`
- User Config:      `-`
- Runtime Modules:  `-`
- Build Modules:    `-`
------------------------------
1个回答

这是解决方案:

https://github.com/nuxt/framework/issues/3770

运行:

npm up c12
47ndr
2022-03-18