使用Vite的嵌套目录Nuxt 3
P粉364642019
P粉364642019 2024-02-17 11:10:23
0
1
364

我想在 nuxt 3 beta 中使用 vite 的嵌套目录。

在 Nuxt 2 中,我在 (nuxt.config.js) 中使用了这个配置,它可以工作:

components: [
{
  path: '~/components', // will get any components nested in let's say /components/test too
  pathPrefix: false,
},],

我有这个目录组织:

| components
 - Header.vue
 - Footer.vue
 | sections
  - HeroSection.vue

但是当我尝试将 <HeroSection/> 放入 pages/index.vue 时出现此错误。

[Vue warn]: Failed to resolve component: HeroSection
If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.
Invalid value used as weak map key

它在 nuxt 3 中不再工作并且需要进行其他配置吗?因为我在文档中找不到任何相关内容

感谢<3

P粉364642019
P粉364642019

全部回复(1)
P粉652495194

使用嵌套目录需要将目录名称添加到组件上:


通过这种行为,您可以简化组件命名的复杂性:

- components
    Header.vue
    Footer.vue
  - Sections
      Hero.vue

这样我们就可以像这样使用


在此处的文档中阅读更多内容:https://v3. nuxtjs.org/guide/directory-struct/components#component-names

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!