(二)Vue中使用animate.css

2018-10-04  本文已影响0人  我拥抱着我的未来

本节知识点

实现

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>

<body>
  <div id="app">
    <transition name="fade">
      <div v-if="show">Hello World</div>
    </transition>

    <button @click="change">点击切换</button>
  </div>
</body>
<script>
  let app = new Vue({
    el: "#app",
    data: {
      message: "Hello World!",
      show: true
    },
    methods: {
      change() {
        this.show = !this.show;
      }
    },
  })
</script>
<style>
  * {
    margin: 0px;
    padding: 0px;
  }
  
  #app {
    font-size: 24px;
    color: #000;
  }
  /*动画开始到结束有*/
  
  @keyframes bounce-in {
    0% {
      transform: scale(0);
    }
    50% {
      transform: scale(1.5);
    }
    100% {
      transform: scale(1);
    }
  }
  
  .fade-enter-active {
    transform-origin: left center;
    animation: bounce-in 1s;
  }
  /*动画开始到结束有*/
  
  .fade-leave-active {
    transform-origin: left center;
    animation: bounce-in 1s reverse;
  }
</style>

</html>
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<link rel="stylesheet" href="css/animate.min.css">

<body>
  <div id="app">
    <transition enter-active-class="animated swing" leave-active-class="animated shake">
      <div v-if="show">Hello World</div>
    </transition>

    <button @click="change">点击切换</button>
  </div>
</body>
<script>
  let app = new Vue({
    el: "#app",
    data: {
      message: "Hello World!",
      show: true
    },
    methods: {
      change() {
        this.show = !this.show;
      }
    },
  })
</script>
<style>
  * {
    margin: 0px;
    padding: 0px;
  }
  
  #app {
    font-size: 24px;
    color: #000;
  }
</style>

</html>
上一篇下一篇

猜你喜欢

热点阅读