I have two buttons, on clicking of one button i need to make an element slide vue transition effect, on clicking of other button i need to make an element fade vue transition effect.
<template>
<transition :name="transition ? 'slide-fade' : 'fade'">
<p>Hello world</p>
</transition>
<button @click="shouldSlide">Slide</button>
<button @click="shouldFade">Fade</button>
<template>
<script>
export default {
data () {
return {
isSlide: false
}
},
computed: {
transition () {
return this.isSlide
}
},
methods: {
shouldSlide () {
this.isSlide = true
},
shouldFade () {
this.isSlide = false
}
}
}
</script>
i know it won't work, because computed happens after the template update. Is there any other way to solve this. Thanks in advance.