未知的自定义元素 - 您是否正确注册了组件?

时间:2017-04-12 19:46:14

标签: javascript vuejs2 ecmascript-5

我目前正在使用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

1 个答案:

答案 0 :(得分:2)

这是一个非常古老的问题,但回答以便未来的访问者可能会得到帮助:

自定义元素不应自动关闭:

<information :bleh="{}" />

请务必使用如下:

<information :bleh="{}"></information>

感谢@connexo发表评论:

  

另外,为了符合官方网络组件,请务必使用<information-component ...></information-component>

之类的虚线标记

对于那些因以下原因而收到错误的人:

  

您是否正确注册了该组件?

Make sure to apply the name option in your component

相关问题