Vue實現動畫的幾種方式


1. vue內置組件transition

  元素出現和消失都呈現動畫

<!-- 將要使用動畫的內容放在transition里即可 -->
<transition name="fade">
  <div v-show="show"></div>
</transition>
.fade-enter-active,
.fade-leave-active {
  transition: opacity .5s
}
.fade-enter,
.fade-leave-active {
  opacity: 0
}

2. animate.css插件

  參照https://github.com/daneden/animate.css

  加入類名時呈現動畫

npm install animate.css --save
import animate from 'animate.css'
<div class="animated bounce delay-2s faster">Example</div>

3. wow.js

  需引入animate,滾動到元素的位置展現動畫

npm install wowjs --save-dev
<script>
import { WOW } from "wowjs"
import 'animate.css'
export default {
  mounted() {
    window.addEventListener("scroll", this.handleScroll);
    this.$nextTick(() => {
      new WOW({live: false}).init();
 }); }, </script>
<div class="wow rollIn" />

4. 原生css動畫


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM