I am trying to build a front end web application in Vue. In one of my components, it renders a table and I am trying to use a child component to fill in some of the table data. The child component is in a for loop of the table row in the table body.
ParentComponent.vue:
<table>
<thead>
<tr>
<th>Header 1</th>
<th>Header 2</th>
<th>Header 3</th>
<th>Header 4</th>
</tr>
</thead>
<tbody>
<tr v-for="looping">
<td>Data</td>
<ChildComponent/>
</tr>
</tbody>
</table>
ChildComponent.vue:
<span>
<td>Data1</td>
<td>Data2</td>
<td>Data3</td>
</span>
The problem I have is that when it makes the table, all the data in the component go into the same column. Is there a way to make the table data spread across the table to have the data be in their respective columns?
EDIT: the code provided above are inside template tags.
v-slot.templateinstead ofspanin child componentspantag cannot be the first child oftr. In addition, I suggest that you should encapsulate<tr>...</tr>as a whole in ChildComponent.