I have two components, an item
component and a folder
component. Each item
contains it's own folder
component, and each folder
component contains a list of item
s.
So I am trying to use the item
component in the folder
component, and vice versa, however, I am getting the error: unknown custom element: <item> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
Despite the fact that I have the name
option set on both components.
Any ideas?
Code is below
item.vue
<template>
<div class="item" style="height: 30px">
. . .
<folder v-if="item.hasChildren" :id="id"></folder>
</div>
</template>
<script scoped>
import Folder from './folder.vue';
export default {
name: 'item',
props: ['id'],
components: {
Folder
}
};
</script>
folder.vue
<template>
<div class="folder">
<template v-for="(child, index) in children">
<item :last-item="index === children.length - 1" :key="child.id" :id="child.id"></item>
</template>
</div>
</template>
<script>
import Item from "./item.vue";
export default {
name: 'folder',
props: ['id', 'hasChildren'],
components: {
Item
}
};
</script>