我在半透明背景上呈现了一个模态。两个元素都有一个v-if
由相同的变量控制。
虽然enter
过渡动画效果很好,但 `leave` 过渡动画被忽略了(它应该平滑地淡出,而是立即消失)。为什么?
标记:
<div id="app">
<button @click="showModal = !showModal">Toggle Modal</button>
<div v-if="showModal" class="modalBackdrop">
<transition name="content" appear>
<div v-if="showModal" class="modalContent">
Modal
</div>
</transition>
</div>
</div>
CSS:
.content-enter-active {
animation: slide-up .75s;
}
.content-leave-active {
animation: fade-out .75s;
}
@keyframes slide-up {
0% {
transform: translateY(100%);
}
100% {
transform: translateY(0);
}
}
@keyframes fade-out {
0% {
opacity: 1;
}
100% {
opacity: 0;
}
}