安装
cnpm install wowjs -S
- 根组件加入animate.css 的CDN
<link href="https://cdn.jsdelivr.net/npm/animate.css@3.5.1" rel="stylesheet" type="text/css" />
使用
- 封装util注册方法
import {
onMounted } from 'vue'
import {
WOW } from 'wowjs'
// wow swing
export default () => {
onMounted(() => {
var wow = new WOW({
boxClass: 'wow', // animated element css class (default is wow)
animateClass: 'animated', // animation css class (default is animated)
offset: 0, // distance to the element when triggering the animation (default is 0)
mobile: true, // trigger animations on mobile devices (default is true)
live: true, // act on asynchronously loaded content (default is true)
callback: function (box) {
},
scrollContainer: null, // optional scroll container selector, otherwise use window,
resetAnimation: true // reset animation on end (default is true)
})
wow.init()
})
}
- 组件中使用
-
- data-wow-duration 设置动画时间
-
- data-wow-delay