I am trying to make a custom component that calls the 'list' version of itself. i keep getting an error
Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option.
I have included a name option as you can see below but this doesn't solve the problem.
Any idea what it could be?
TestCompList.vue
<-- The List component
<template>
<div>
<p>I am a list</p>
<template v-for="block in blocks">
<test-comp :name="block.name" :header="block.name" :more="block.more" :key="block.id"></test-comp>
</template>
</div>
</template>
<script>
import TestComp from './TestComp';
export default {
name: "TestCompList",
components: {
TestComp
},
props: ['blocks'],
}
</script>
TestComp.vue
<--- The Single component
<template>
<div>
<h3>{{header}}</h3>
<p>{{name}}</p>
<div class="mr-5" v-if="more">
<test-comp-list :blocks="more"></test-comp-list>
</div>
</div>
</template>
<script>
import TestCompList from './TestCompList';
export default {
name: "TestComp",
props: ['header', 'name', 'more'],
components: {
TestCompList
}
}
</script>
Page.vue
<-- The page passing the data
<template>
<div>
<h3>Testing Recursive components</h3>
<test-comp-list :blocks="blocks"></test-comp-list>
</div>
</template>
<script>
import TestCompList from "./TestCompList";
export default {
components: {
TestCompList
},
data() {
return {
blocks: [
{
id: 1,
name: "test1",
header: "test1Header"
},
{
id: 2,
name: "test2",
header: "test2Header"
},
{
id: 3,
name: "test3",
header: "test3Header",
more: [
{
id: 4,
name: "test4",
header: "test4Header"
},
{
id: 5,
name: "test5",
header: "test5Header",
more: [
{
id: 6,
name: "test6",
header: "test6Header"
},
{
id: 7,
name: "test7",
header: "test7Header"
}
]
}
]
}
]
};
}
};
</script>
Any ideas? I solved a similar problem here -> Vuejs: Dynamic Recursive components
But can't seem to apply the solution here. Worst part is sometimes it seems to work and sometimes it doesn't
Help! What could i be missing?