需要的資源
wowjs 依賴animate.css 需要單獨安裝 wowjs githup 地址 https://github.com/matthieua/WOW#readme npm 地址 https://github.com/animate-css/animate.css animate.css 地址 npm install animate.css --save 使用步驟 1. npm install wowjs --save-dev 2. npm install animate.css --save vue 注冊wowjs
main.js import 'animate.css/animate.min.css' app.vue import { WOW } from 'wowjs' watch: { $route(to, from) { this.$nextTick(() => { new WOW({ mobile: true, live: true, scrollContainer: '.layout-content' }).init() }) } }, 使用 <div class="trait-item wow bounceInUp" data-wow-duration="1s" :data-wow-delay="index + 5 + 's'" v-for="(item, index) in traits" :key="index" > <img :src="item.img" alt="" /> </div> 注意 1.scrollContainer 放實際滾動的容器 一般不用填此項 2. 引入wowjs 和初始化方式 元素 消失不見 概率是容器填錯了 例如 移動端 底部為tabbar 瀏覽器實際沒有滾動 wow是根據容器滾動判斷才執行顯示的
有問題查官方文檔才是最好的方法 鏈接上面有
使用的包相應版本
"wowjs": "^1.1.3"
"animate.css": "^3.7.2"