Answer the question
In order to leave comments, you need to log in
How to do v-if with v-for correctly in vue?
I would like to make a condition, let's say when the name is Tom or Misha, then let's add the number 9 to it. To get a list, but under my condition it was Tom 9, Alex, Vasya, Misha 9. How can this be implemented? also read that v-for cannot be used with v-if
Example:
https://codepen.io/Unknown322/pen/zYOVMPw
Answer the question
In order to leave comments, you need to log in
also read that v-for cannot be used with v-ifnot recommended does not mean it is not recommended, it is recommended to do .filter on the array, and already do v-for on the filtered array and this is due to the fact that vue can cache the filtered array and recalculate cycles only when the array itself changes, but does not respond to changes in elements in German
<li v-for="user in users"
:key="user"
>
<p>Имя: {{ user }}{{ user === 'Tom' || user === 'Misha' ? ' 9' : '' }}</p>
</li>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question