模糊错误说我的组件名称以零开头 [英] Obscure error says my component name begins with a zero
问题描述
我收到一个模糊的错误,我的组件名称为零.但是我的组件中没有一个名称为零.这个错误很难追查.任何人都知道问题可能是什么,所以我可以朝着正确的方向前进以解决它.
I am getting an obscure error that my component name is zero. But none of my components have a zero for a name. This error is hard to track down. Anyone know what the problem could be so I can move in the right direction to tackle it.
vendor.js:66537 [Vue 警告]:组件名称无效:0".组件名称只能包含字母数字字符和连字符,并且必须以字母开头.
vendor.js:66537 [Vue warn]: Invalid component name: "0". Component names can only contain alphanumeric characters and the hyphen, and must start with a letter.
以下是有关错误的更多信息:
Heres more information on the error:
编辑:更多信息:
我有一个独特的项目结构.我有单个文件组件.每个组件被分成 2 个文件,如下所示:
I have a unique project structure. I have single file components. And each component is split into 2 files like so:
Home.vue:
<template>
...
</template>
<style lang="scss">
...
</style>
<script src="./home.js"></script>
home.js:
export default {
...
}
调试捕获
home.js
import RecentPostsWidget from './widgets/RecentPosts'
import PagesWidget from './widgets/Pages'
export default {
components: {
RecentPostsWidget,
PagesWidget
}
}
推荐答案
我遇到了同样的错误,它是由组件中使用数组而不是对象引起的.应该是这个样子
I had the same error and it was caused by use of array instead of object in the components. This is how it should looks like
components: {
RecentPostsWidget,
PagesWidget
}
当错误出现时我是这样的:
This is how I had it when the error appeared:
components: [
RecentPostsWidget,
PagesWidget
]
这篇关于模糊错误说我的组件名称以零开头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!