Vue CSS动画原理

2020-02-08  本文已影响0人  wdapp

完整代码:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Vue中CSS动画原理</title>
  <style>
    .v-enter, .v-leave-to  {
      opacity: 0
    }
    .v-enter-active, .v-leave-active {
      transition: opacity 3s;
    }
    .fd-enter, .fd-leave-to  {
      opacity: 0
    }
    .fd-enter-active, .fd-leave-active {
      color: red;
      transition: opacity 3s;
    }
  </style>
  <script src="js/vue.js"></script>
</head>
<body>
<div id="app">
  <transition>
    <div v-if="isShow">
      <p>hello world</p>
      <p>hello world</p>
    </div>
  </transition>
  <transition name="fd">
    <div v-show="isShow">hello world</div>
  </transition>

  <button @click="handleClick">按钮</button>
</div>
<script>
  var app = new Vue({
    el: '#app',
    data: {
      isShow: true
    },
    methods: {
      handleClick () {
        this.isShow = !this.isShow
      }
    }
  })
</script>
</body>
</html>

上一篇 下一篇

猜你喜欢

热点阅读