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>

 

posted @ 2020-02-20 12:44  聂小恶  阅读(516)  评论(0编辑  收藏  举报