:::

6-1 transition + keyframes

  1. 範例:
    <script>
    import { ref } from "vue";
    export default {
      setup() {
        const isAmin = ref(false);
        const goAmin = () => {
          isAmin.value = !isAmin.value;
        };
        return { isAmin, goAmin };
      },
    };
    </script>
    
    <template>
      <button @click="goAmin">click</button>
      <transition name="tad">
        <div id="box" v-if="isAmin"></div>
      </transition>
    </template>
    
    <style>
    .tad-enter-active {
      animation: tad-in 0.5s;
    }
    .tad-leave-active {
      animation: tad-in 0.5s reverse;
    }
    @keyframes tad-in {
      0% {
        transform: scale(0);
      }
      50% {
        transform: scale(1.25);
      }
      100% {
        transform: scale(1);
      }
    }
    
    #box {
      width: 100px;
      height: 100px;
      background-color: rgb(109, 148, 111);
    }
    </style>
    

     

  2. reverse 是反轉之意

範例內容:


:::

書籍目錄

展開 | 闔起

快速登入


https%3A%2F%2Fcampus-xoops.tn.edu.tw%2Fmodules%2Ftad_book3%2Fpage.php%3Ftbdsn%3D1740%26tbsn%3D33

計數器

今天: 4259425942594259
昨天: 2489248924892489
總計: 8026241802624180262418026241802624180262418026241