给Vue项目快速加上炫酷的动画

562 阅读1分钟

平时项目中有不少需要用到动画的地方,自己写动画又太浪费时间。那么有没有能够快速给项目加上动画的东西呢?

答案毋庸置疑是有的。这里我们使用的是Animate.css,一个封装好的动画库。

官网地址:animate.style/

使用步骤

1.下载安装Animate动画库,使用npm或者yarn等命令安装(二者选其一)

$ npm install animate.css --save
$ yarn add animate.css

2.在项目中全局引入Animate.css库(main.ts)



import { createApp } from 'vue'

// 此处引入 Animate.css 动画库
import 'animate.css'


import 'element-plus/theme-chalk/dark/css-vars.css'

import router from './router'
import App from './App.vue'

const app = createApp(App)

app.use(router)
app.mount('#app')


3.打开Animate.css官网,挑喜欢的动画效果

官网:animate.style/

A.png

4.在页面使用动画

官网每个动画属性后面都有复制按钮,你只需挑选好动画然后复制它即可!


// 在要添加动画的地方 使用动画属性

 <div class="page-body animate__animated animate__bounceInRight">
  
  <!--  数据列表  -->
 </div>

注:在class='animate__animated animate__bounceInRight'中,animate__animated属性是必须添加的,后面接动画效果属性。否则动画无法生效。

文章只介绍了使用方法,具体动画请见官网

animate.style/

About Me

lucky0119.github.io/

原创文章,记录成长,也希望对你有帮助!喜欢请点赞哦~

作者:Lucky-2000

主页:了解更多,点击个人主页