最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Animating simple v-if directive in Vue - Stack Overflow

programmeradmin2浏览0评论

Is it possible to animate, more specifically "fadeOut" a div when it is being removed/destroyed do to a v-if conditional?

I have the most basic conditional:

<template v-if="initProxy">
  <div class="page__boot">
  <div>
</template>

In my ponents data prop, when I set initProxy to false, I'd like to fadeOut the rendered div before its destroyed, rather than it just abruptly disappearing. I know I'm missing something so trivial... suggestions?

Is it possible to animate, more specifically "fadeOut" a div when it is being removed/destroyed do to a v-if conditional?

I have the most basic conditional:

<template v-if="initProxy">
  <div class="page__boot">
  <div>
</template>

In my ponents data prop, when I set initProxy to false, I'd like to fadeOut the rendered div before its destroyed, rather than it just abruptly disappearing. I know I'm missing something so trivial... suggestions?

Share Improve this question asked Feb 20, 2018 at 12:02 Jared GarciaJared Garcia 7911 gold badge9 silver badges19 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 4

You should follow this basic example

<template>
  <transition name="fade">
    <div class="page__boot" v-if="initProxy">
    <div>
  </transition>
</template>

And adjust your animation:

.fade-enter-active, .fade-leave-active {
  transition: opacity .5s;
}
.fade-enter, .fade-leave-to /* .fade-leave-active below version 2.1.8 */ {
  opacity: 0;
}

Also you can change duration for .fade-leave-active

发布评论

评论列表(0)

  1. 暂无评论