我目前正在使用webpack和vuejs 2.我有一个非常基本的组件[Main.vue]由vue-router渲染,在这个组件中,我想要另一个[Information.vue]。出于某种原因,我无法正确渲染它。
组件/测试/ Information.vue
<template>
<div>
TEST
</div>
</template>
<script>
export default {
name: 'information',
props: {
bleh: {
type: Object,
required: true
}
}
}
</script>
组件/测试/ injex.js
export { default as Main } from './Main'
export { default as Information } from './Information'
组件/测试/ Main.vue
<template>
<information :bleh="{}" />
</template>
<script>
import { Information } from 'components/test'
export default {
name: 'main',
components: { Information }
}
</script>
我知道为什么会出现以下错误?
[Vue warn]: Unknown custom element: <information> - did you register
the component correctly? For recursive components, make sure to
provide the "name" option
答案 0 :(得分:2)
这是一个非常古老的问题,但回答以便未来的访问者可能会得到帮助:
自定义元素不应自动关闭:
<information :bleh="{}" />
请务必使用如下:
<information :bleh="{}"></information>
感谢@connexo发表评论:
另外,为了符合官方网络组件,请务必使用
之类的虚线标记<information-component ...></information-component>
对于那些因以下原因而收到错误的人:
您是否正确注册了该组件?