在Vue中同时使用过渡和动画

实现既有过渡效果又有动画效果;

<!DOCTYPE html>
<html lang="en" dir="ltr">

<head>
  <meta charset="utf-8">
  <title>在Vue中同时使用过渡和动画</title>
  <script src="./vue.js"></script>
  <link rel="stylesheet" href="./animate.css">
  <style media="screen">
    .fade-enter,.fade-leave-to{
      opacity:0;
    }
    .fade-enter-active,.fade-leave-active{
      transition:opacity 3s;
    }
  </style>
</head>

<body>
  <div id="root">
    <transition
      type="transition"
      :duration="{
        enter:5000,leave:10000
      }"
      name="fade"
      appear
      enter-active-class="animated swing fade-enter-active"
      leave-active-class="animated shake fade-leave-active"
      appear-active-class="animated swing"
    >
      <div v-if="show">
        hello world
      </div>
    </transition>
    <button @click="handleClick">change</button>
  </div>
  <script type="text/javascript">
    var vm = new Vue({
      el: '#root',
      data: {
        show: true
      },
      methods: {
        handleClick: function() {
          this.show = !this.show
        }
      }
    })
  </script>
</body>

</html>

推荐阅读更多精彩内容