vue中的css 动画过渡效果


https://segmentfault.com/a/1190000018125564  很完善了,重点是两个过程图。

 <style> .fade-enter{ opacity: 0; } .fade-enter-active{ transition: opacity 3s; }
      /* .fade-enter-to{
        color: red;
      }
      .fade-leave{
        color: green;
      } */ .fade-leave-to{ opacity: 0;
      } .fade-leave-active{ transition: opacity 3s;
      }
  </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'>
      <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>

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM