Answer the question
In order to leave comments, you need to log in
How to correctly handle the condition when drawing the list?
Tell me how to correctly add a condition and draw another row in the table when the list is drawn.
Those. if my object has the "total" key, I want to add one more line ....
It's not clear where I should write v-if="item.total"
<table>
<thead>.....</thead>
<tbody>
<tr v-for="item in data" :key="item.id">
<td>{{ item.value1 }}</td>
<td>{{ item.value2 }}</td>
<td>{{ item.value3 }}</td>
// Как мне правильно прописать условие v-if, что бы я мог при наличии ключа "total" добавить ещё одну строку таблици
// на js при переборе массива через forEach, я бы просто добавил: '</tr><tr><td colspan="3">{{ item.total }}</td>
</tr>
</tbody>
</table>
// Грубо говоря в итоге я хочу получить вот так
<table>
<thead>.....</thead>
<tbody>
<tr>
<td>....</td>
<td>....</td>
<td>....</td>
</tr>
<tr>
<td>....</td>
<td>....</td>
<td>....</td>
</tr>
<tr>
<td>....</td>
<td>....</td>
<td>....</td>
</tr>
<tr>
<tr><td colspan="3">total</td>
</tr>
</tbody>
</table>
Answer the question
In order to leave comments, you need to log in
<tbody>
<template v-for="item in data">
<tr>...</tr>
<tr v-if="...">...</tr>
</template>
</tbody>
I think it's better to do without the regex in this case.
$str = 'Toster классный сайт';
$final_str = mb_substr($str, mb_strpos($str, ' '));
$str = 'Toster классный сайт';
$final_str = preg_replace('~^(.*?)\s~', '', $str);
var_dump($final_str);
Find the position of the first occurrence of the space character in the string, remove from the string the number of characters from the beginning equal to the space position.
$str=strpos($row, " ");
$row=substr($row, 0, $str);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question