Vue: For recursive components, make sure to provide the "name" option. But name is provided for all components.

Created on 11 Sep 2018  路  6Comments  路  Source: vuejs/vue

Version

2.5.17

Reproduction link

https://jsfiddle.net/gjx1wvhk/

Steps to reproduce

Just run the code

What is expected?

No error

What is actually happening?

Shows error in console


Hi, I use *.vue components, and I have following error: "Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option." for my component. However I provided names for all components.

Here is sample fiddle to reproduce this error:
https://jsfiddle.net/gjx1wvhk/ (open developer console to see error)

There is small difference between fiddle and my code, I use *.vue components, import them relatively and add as components fields to my components:

import CommentsList from './CommentsList.vue'

export default {
  name: 'comments',

  components: {
    CommentsList,
  },
...
}

import CommentsList from './CommentsList.vue'

export default {
  name: 'comment',

  components: {
    CommentsList,
  },
...
}

import Comment from './Comment.vue'

export default {
  name: 'comments-list',

  components: {
    Comment,
  },
...
}

Most helpful comment

There we go: https://vuejs.org/v2/guide/components-edge-cases.html#Circular-References-Between-Components

All 6 comments

This is because both of your components depend on each other. I'm not sure what was the right approach but I'm pretty sure I saw it documented. Maybe it's using a dynamic import in one of the components. cc @chrisvfritz

did you register the component correctly?

The first argument to Vue.component must be a string: https://vuejs.org/v2/api/#Vue-component

There we go: https://vuejs.org/v2/guide/components-edge-cases.html#Circular-References-Between-Components

@posva Thanks a lot!

@KaelWD Re: The first argument to Vue.component must be a string
That was just to make an example, I don't use Vue.component, I use modules with Webpack.

Yeah I kinda glossed over that bit lol, still an error in the repro though. CodeSandbox is usually better for multi-component examples like that, especially when it's something caused by webpack.

i'm having same issue but it's regardig the how come?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

6pm picture 6pm  路  3Comments

franciscolourenco picture franciscolourenco  路  3Comments

loki0609 picture loki0609  路  3Comments

wufeng87 picture wufeng87  路  3Comments

aviggngyv picture aviggngyv  路  3Comments