用Vue 实现animate动画


<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <link rel="stylesheet" href="./animate.min.css" />
    <script src="./vue.js"></script>
    <style>
      .box {
        width: 100px;
        height: 100px;
        background-color: red;
      }
      .custom-enter-active {
        animation-name: zoomIn;
        animation-duration: 10s;
      }
      .custom-leave-active {
        animation-name: zoomOut;
        animation-duration: 2s;
      }
    </style>
  </head>
  <body>
    <div id="app">
      <input type="checkbox" v-model="show" />显示/隐藏
      <hr />
      <!-- 方式一: 使用自定义过渡名 -->
      <transition
        enter-active-class="animate__zoomIn"
        leave-active-class="animate__zoomOut"
      >
        <div class="box animate__animated" v-show="show"></div>
      </transition>
      <br />
      <br />
      <br />
      <!-- 方式二: 使用自定义过渡名 -->
      <transition name="custom">
        <div class="box animate__animated" v-show="show"></div>
      </transition>
    </div>
    <script>
      let vm = new Vue({
        el: "#app",
        data: {
          show: true,
        },
      });
    </script>
  </body>
</html>
 
效果如下:

 

 


免责声明!

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



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