animate和过度动画同时使用.html

1将animate和过度动画的类名添加到transition对应的类上

2appear  设置初始样式(页面刷新样式)appear-active-class

3type设置动画时间依据类型(transition或animate)

4可以通过:duration来设置动画时间,补充3

 <style>
    .fade-enter,.fade-leave-to{
      opacity: 0;
    }
    .fade-enter-active,.fade-leave-active{
      transition: opacity 1s;
    }
  </style>
</head>
<body>
  <!-- 
    过程如下:
     显示  fade-enter,fade-enter-active      fade-enter-active,fade-enter-to     空
     隐藏  fade-leave,fade-leave-active      fade-leave-active,fade-leave-to     空
  -->
  <div id="root">
    <transition name='fade' 
      appear
      appear-active-class='animated tada'
      enter-active-class='animated tada fade-enter-active'
      leave-active-class='animated rubberBand fade-leave-active'
    >
      <h1 v-show='show'>
        最是年少时模样
      </h1>
    </transition>
    <button @click='change'>切换</button>
  </div>
  <script>
    var vm=new Vue({
      el:'#root',
      data:{
        show:true
      },
      methods:{
        change:function(){
          this.show=!this.show;
        }
      }
    })
  </script>
</body>

 

上一篇:Vue C3动画 vue2-animate


下一篇:【插件】animate.css - 加载页面 - 显示动画