【发布时间】:2022-01-15 13:18:16
【问题描述】:
我有简单的转换来切换 div 文本,但是转换仅在隐藏文本时起作用,但是当我单击显示文本时,转换在这里不起作用,这是我的代码:
<template>
<div>
<transition name="fade">
<div v-if="this.showName">My name is Simon</div>
</transition>
<button @click="showName = !showName">Toggle</button>
</div>
</template>
<script>
export default {
data(){
return {
showName: false,
}
},
name: "StatusComponent"
}
</script>
<style scoped>
.fade-enter-from{
opacity: 0;
}
.fade-enter-to{
opacity: 1;
}
.fade-enter-active{
transition: all 2s ease;
}
.fade-leave-from{
opacity: 1;
}
.fade-leave-to{
opacity: 0;
}
.fade-leave-active{
transition: all 2s ease;
}
</style>
【问题讨论】: