在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>
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容