首页 前端知识 报错:has naming conflicts with other components, ignored

报错:has naming conflicts with other components, ignored

2024-08-24 23:08:09 前端知识 前端哥 261 141 我要收藏

Vue 项目编译时,出现如下报错

[unplugin-vue-components] component "xxx"(xxx/Index.vue) has naming conflicts with other components, ignored.
[unplugin-vue-components] component "xxx"(xxx/Index.vue) has naming conflicts with other components, ignored.
[unplugin-vue-components] component "xxx"(xxx/Index.vue) has naming conflicts with other components, ignored.
[unplugin-vue-components] component "xxx"(xxx/Index.vue) has naming conflicts with other components, ignored.
复制

因为本人的个人习惯,在写组件时,通常都是以 Index.vue 进行命名,造成项目拥有大量的同名文件而出现上述报错。

解决方案

unplugin-vue-components 插件配置 directoryAsNamespace 属性为 true 即可。

// vite.config.ts
plugins: [
vue(),
Components({
// ... 其它配置
// 允许子目录作为组件的命名空间前缀
directoryAsNamespace: true
})
]
复制
转载请注明出处或者链接地址:https://www.qianduange.cn//article/16811.html
标签
评论
还可以输入200
共0条数据,当前/页
发布的文章

安装Nodejs后,npm无法使用

2024-11-30 11:11:38

大家推荐的文章
会员中心 联系我 留言建议 回顶部
复制成功!