<div id="app">
  <transition @before-enter="handleBeforeClick" @enter="handlEnterClick" @after-enter="handlAfterClick">
    <div v-show="show">
      {{mess}}
    </div>
  </transition>
  <button @click="handleBtnClick">toggle</button>
</div>
var app = new Vue({
  el: "#app",
  data: {
    mess: "hello world",
    show: true
  },
  methods: {
    handleBtnClick: function () {
      this.show = !this.show;
    },
    // 显示/入场 的时候执行,一个参数
    handleBeforeClick: function (el) {
      el.style.opacity = 0;
    },
    // 显示/入场 的时候执行,两个参数el,done(回调函数)
    handlEnterClick: function (el, done) {
      Velocity(
        el,
        {
          opacity: 1
        },
        {
          duration: 1000,
          complete: done
        }
      );
    },
    handlAfterClick: function (el) {
      alert("动画结束");
    }
  }
});

External CSS

  1. https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/vue/2.7.8/vue.min.js
  2. https://cdnjs.cloudflare.com/ajax/libs/velocity/2.0.6/velocity.min.js