Answer the question
In order to leave comments, you need to log in
How to add tr to table by condition?
There is a table with inputs in the cells where the user enters data, there are several trs in it with the same type of inputs. These tr's are output in a loop. After filling and sending, if there were errors in filling, notifications about them come, which must be displayed under the tr in which these errors were found. In other words, add a new tr under it, in which there will no longer be inputs, but text notifications, then, they say, this is a mistake.
The conclusion is made like this:
<tbody>
<report-table-row
v-for="row in sortingReports"
:key="row.index"
:row="row"
:errors="publicReportsErrors.lines"
/>
</tbody>
<template>
<tr>
<td>Контент с инпутами</td>...
</tr>
</template>
<template>
<tr>
<td>Контент с инпутами</td>...
</tr>
<tr v-if="errors.length">
<td>Контент с уведомлениями</td>...
</tr>
</template>
Answer the question
In order to leave comments, you need to log in
These are the options:
tbody
for each pair of lines. Transfer tbody
from a table component to a row component - it will be the root element there:<tbody>
<tr>... </tr>
<tr v-if="...">...</tr>
</tbody>
tr
directly in the table component:<tbody>
<template v-for="...">
<tr>... </tr>
<tr v-if="...">...</tr>
</template>
</body>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question