Answer the question
In order to leave comments, you need to log in
How to make animation for "v-for" element with "v-if" condition in Vue?
Tried to animate this block with <transition>
and <transition-group>
, but neither works. Can you please tell me how to add animation here?
Here, two different lists are rendered, selected by category from the data.json.js
.
template
<button @click="switch = !switch">SWITCH</button>
<transition name="fade">
<li v-for="elements in myData" v-if="elements.key == getKey()">
<span>{{elements.title}}</span>
</li>
</transition>
data() {
return {
switch: true,
}
getKey(){
if (this.switch) {
return 'KEY'
} else {
return 'ANOTHER KEY'
}
.fade-enter-active, .fade-leave-active {
transition: opacity .5s;
}
.fade-enter, .fade-leave {
opacity: 0;
}
Answer the question
In order to leave comments, you need to log in
switch = !switch
two different lists are rendered
<transition name="fade">
transition-group
.<li v-for="elements in myData" v-if="elements.key == getKey()">
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question