Answer the question
In order to leave comments, you need to log in
[vue.js] How to embed a component within a component?
Let's say I want to get the following structure as a result:
<!-- первый компонент - parent -->
<div id='parent'>
<h1>Title</h1>
<!-- второй компонент - child -->
<ul id='child'>
<!-- несколько третьих компонентов - grandchild -->
<li class='grandchild'><span>smth</span></li>
<li class='grandchild'><span>smth</span></li>
<li class='grandchild'><span>smth</span></li>
</ul>
</div>
Vue.component('parent', {/* code */});
Vue.component('child', {/* code */});
Vue.component('grandchild', {/* code */});
Answer the question
In order to leave comments, you need to log in
// child template
<template>
<ul>
<slot></slot>
</ul>
</template>
<parent>
<child>
<granchild v-for="item in items"></grandchild>
</child>
</parent>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question