赞
踩
npm i animate.css
在main.ts文件中引入
// 引入动画库
import "animate.css"
注意安装animate.css版本,我这里用的v4.1.1 ,animate__animated是基类必须使用的(因为安装的animate版本是4.x,使用时要注意对应的所有类名都以animate__开头,并且还要配合animate__animated一起使用!)
//注意这里必须加animate__animated基类
<div class="animate__animated animate__fadeInDown"></div>
结合了vue中过渡&动画里的内容,自定义过渡 class 类名。
可以通过以下 attribute 来自定义过渡类名:
<div
enter-active-class="animate__animated animate__bounce"
leave-active-class="animate__animated animate__bounce"
>
将要添加动画效果的dom元素
</div>
有时需要搭配 wow.js实现动画
npm install wow.js
npm i animate.css
在main.ts文件中引入
// 引入动画库
import "animate.css"
在main.ts 或者App.vue中初始化
import WOW from 'wow.js';
let 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: any) {
// the callback is fired every time an animation is started
// the argument that is passed in is the DOM node being animated
},
scrollContainer: null, // optional scroll container selector, otherwise use window
});
wow.init();
import WOW from 'wow.js';
let 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: any) {
// the callback is fired every time an animation is started
// the argument that is passed in is the DOM node being animated
},
scrollContainer: null, // optional scroll container selector, otherwise use window
});
wow.init();
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。