source

알 수 없는 사용자 지정 요소 - 구성 요소를 올바르게 등록했습니까?

goodcode 2022. 8. 14. 11:58
반응형

알 수 없는 사용자 지정 요소 - 구성 요소를 올바르게 등록했습니까?

현재 vuejs 2에서 웹 팩을 사용하고 있습니다.매우 기본적인 컴포넌트 [Main]가 있습니다.vue]는 vue-router에 의해 렌더링되며, 이 컴포넌트 내에 다른 [Information.vue]가 필요합니다.웬일인지 제대로 렌더링할 수가 없어요.

컴포넌트/테스트/정보.표시하다

<template>
    <div>
    TEST
    </div>
</template>

<script>
export default {
  name: 'information',
  props: {
    bleh: {
      type: Object,
      required: true
    }
  }
}
</script>

컴포넌트 / 테스트 / 테스트 / 컴포넌트 / 컴포넌트.

export { default as Main } from './Main'
export { default as Information } from './Information'

컴포넌트/테스트/메인표시하다

<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

이것은 매우 오래된 질문이지만, 향후의 방문자에게 도움이 될 수 있도록 대답합니다.

사용자 지정 요소는 자동으로 닫히지 않아야 합니다.

<information :bleh="{}" />

반드시 다음과 같이 사용해 주세요.

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

코멘트를 주신 @connexo님 감사합니다.

또한 공식 웹 컴포넌트를 준수하려면 다음과 같은 점선 태그를 사용하십시오.<information-component ...></information-component>

다음과 같은 오류가 발생한 경우:

컴포넌트를 올바르게 등록했습니까?

컴포넌트에 name 옵션을 적용합니다.

구성 요소를 직접 등록해 보십시오.이걸로 고쳤어요.

Vue.component('Information', Information)

언급URL : https://stackoverflow.com/questions/43378354/unknown-custom-element-did-you-register-the-component-correctly

반응형