Answer the question
In order to leave comments, you need to log in
How to properly solve a problem with VueJS?
The question is not only about VueJS.
The case is this:
<div v-for="day in days">
<div v-for="item in items" v-if="$index < 3 || showItem[$index]">
{{ item }}
</div>
<a @click="change($index)">Show</a>
</div>
$index
from day
. div
in, v-if
I show no more than three elements, but there is an OR condition - if showItem[$index] === true
, then you still need to show the element, by default this parameter is false. And it changes by the Show button . There are as many elements in the showItem
days
Answer the question
In order to leave comments, you need to log in
<div v-for="(day_index, day) in days">
<div v-for="(item_index, item) in items" v-if="item_index < 3 || showItem[day_index]">
{{ item }}
</div>
<a @click="change(day_index)">Show</a>
</div>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question