Vue使用Animate.css

说一下Animate.css这个动画库,很多的动画在这个库里面都定义好了,我们用的时候可以直接使用里面的类名就可以了,就是直接目标元素绑定对应的类名就可以实现动画效果,非常方便,库其实也相对简单,使用起来也简单。这里示例就以v3为例了,v2也是一样的

github:https://github.com/animate-css/animate.css 

官网:https://animate.style/ 

首先安装

pnpm add animate.css

引入 

main.js 

import 'animate.css'

使用

接下来就可以正常使用了 

注意:在添加类名的时候,里面所有的动画必须先设置上 animate__animated ,然后再设置对应动画的类名,否则是不会生效的,大家简单看一下源码就能了解

下面是个示例: 

 

接下来代码: 

<template><div class="main"><label for=""><span style="fontSize: 13px;margin-right: 5px;">开启无限轮询</span></label><input v-model="isInfinite" type="checkbox"><div class="animates-container"><button v-for="animateName in animateNames1" :key="animateName" @click="setAnimate(animateName)">{{ animateName }}</button></div><div class="animates-container"><button v-for="animateName in animateNames2" :key="animateName" @click="setAnimate(animateName)">{{ animateName }}</button></div><div class="animates-container"><button v-for="animateName in animateNames3" :key="animateName" @click="setAnimate(animateName)">{{ animateName }}</button></div><div class="animates-container"><button v-for="animateName in animateNames4" :key="animateName" @click="setAnimate(animateName)">{{ animateName }}</button></div><div class="animates-container"><button v-for="animateName in animateNames5" :key="animateName" @click="setAnimate(animateName)">{{ animateName }}</button></div><div class="animates-container"><button v-for="animateName in animateNames6" :key="animateName" @click="setAnimate(animateName)">{{ animateName }}</button></div><div class="animates-container"><button v-for="animateName in animateNames7" :key="animateName" @click="setAnimate(animateName)">{{ animateName }}</button></div><div class="animates-container"><button v-for="animateName in animateNames8" :key="animateName" @click="setAnimate(animateName)">{{ animateName }}</button></div><div class="animates-container"><button v-for="animateName in animateNames9" :key="animateName" @click="setAnimate(animateName)">{{ animateName }}</button></div><div class="animates-container"><button v-for="animateName in animateNames10" :key="animateName" @click="setAnimate(animateName)">{{ animateName }}</button></div><div class="testAnimate" :class="[`${animationsClass()}`, { 'animate__infinite': isInfinite }]"></div></div>
</template>
<script setup>
import { ref } from 'vue'
let animateNames1 = ['bounce','flash','pulse','rubberBand','shakeX','shakeY','headShake','swing','tada','wobble','jello','heartBeat',
]
let animateNames2 = ['backInDown','backInLeft','backInRight','backInUp','backOutDown','backOutLeft','backOutRight','backOutUp'
]
let animateNames3 = ['bounceIn','bounceInDown','bounceInLeft','bounceInRight','bounceInUp','bounceOut','bounceOutDown','bounceOutLeft','bounceOutRight','bounceOutUp',
]
let animateNames4 = ['fadeIn','fadeInDown','fadeInDownBig','fadeInLeft','fadeInLeftBig','fadeInRight','fadeInRightBig','fadeInUp','fadeInUpBig','fadeInTopLeft','fadeInTopRight','fadeInBottomLeft','fadeInBottomRight','fadeOut','fadeOutDown','fadeOutDownBig','fadeOutLeft','fadeOutLeftBig','fadeOutRight','fadeOutRightBig','fadeOutUp','fadeOutUpBig','fadeOutTopLeft','fadeOutTopRight','fadeOutBottomRight','fadeOutBottomLeft'
]
let animateNames5 = ref(['flip','flipInX','flipInY','flipOutX','flipOutY'
])
let animateNames6 = ref(['lightSpeedInRight','lightSpeedInLeft','lightSpeedOutRight','lightSpeedOutLeft'
])
let animateNames7 = ref(['rotateIn','rotateInDownLeft','rotateInDownRight','rotateInUpLeft','rotateInUpRight','rotateOut','rotateOutDownLeft','rotateOutDownRight','rotateOutUpLeft','rotateOutUpRight'
])
let animateNames8 = ref(['hinge','jackInTheBox','rollIn','rollOut'
])
let animateNames9 = ref(['zoomIn','zoomInDown','zoomInLeft','zoomInRight','zoomInUp','zoomOut','zoomOutDown','zoomOutLeft','zoomOutRight','zoomOutUp'
])
let animateNames10 = ref(['slideInDown','slideInLeft','slideInRight','slideInUp','slideOutDown','slideOutLeft','slideOutRight','slideOutUp'
])let animates = ref([])
let isInfinite = ref(false)const setAnimate = animateName => {animates.value.shift()animates.value.push(animateName)
}const animationsClass = () => {if (animates.value.length) {return `animate__animated animate__${animates.value[0]}`}return ''
}
</script>
<style scoped>
.main {width: 100%;height: 100%;padding: 40px 0 0 50px;box-sizing: border-box;overflow: hidden;
}
.main button {margin-right: 8px;cursor: pointer;
}.animates-container {margin: 20px 0;
}.main .testAnimate {width: 300px;height: 300px;background-color: red;margin: 50px 0 0 10px;padding: 30px;box-sizing: border-box;
}
</style>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/101486.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

数据结构(3)

线性表是多个具有相同特征的数据的有限序列。 前驱元素&#xff1a;A在B前面&#xff0c;称A为B的前驱元素。 后继元素&#xff1a;B在A后面&#xff0c;称B为A的后继元素。 线性表特征&#xff1a; 1.一个元素没有前驱元素&#xff0c;就是头结点&#xff1b; 2.最后一个…

法线矩阵推导

法线矩阵推导 https://zhuanlan.zhihu.com/p/72734738 https://juejin.cn/post/7113952418613690382 https://blog.csdn.net/wangjianxin97?typeblog 1、为什么需要法线矩阵 vec3 normalEyeSpace modelViewMatrix * normal;如果模型矩阵执行了非等比缩放, 顶点的改变会导致法…

PSP - 蛋白质结构预测 AlphaFold2 的结构模版 (Template) 搜索与特征逻辑

欢迎关注我的CSDN&#xff1a;https://spike.blog.csdn.net/ 本文地址&#xff1a;https://spike.blog.csdn.net/article/details/132427617 结构模版 (Template) 是一种已知的蛋白质结构&#xff0c;可以作为 AlphaFold2 蛋白质结构预测的参考&#xff0c;AlphaFold2 可以从多…

springMVC 已解密的登录请求

问题描述&#xff1a; 解决方案&#xff1a; 1.对用户所输入的密码在页面进行MD5加密并反馈至密码输入框。 2. 手动生成SSL安全访问证书&#xff1b;在此不做介绍&#xff0c;相关方法可通过网上查找&#xff1b; 3. 将产品HTTP访问方式改为SSL安全访问方式&#xff1b;在Ap…

【C++】STL——map的介绍和使用、map的构造函数、map的迭代器、map的容量和访问函数、map的增删查改函数

文章目录 1.map的介绍2.map的使用2.1map的构造函数2.2map的迭代器2.3map的容量和访问函数2.4map的增删查改函数 1.map的介绍 map的介绍 &#xff08;1&#xff09;map是关联容器&#xff0c;它按照特定的次序(按照key来比较)存储由键值key和值value组合而成的元素。 &#xff…

【React学习】React组件生命周期

1. 介绍 在 React 中&#xff0c;组件的生命周期是指组件从被创建到被销毁的整个过程。React框架提供了一系列生命周期方法&#xff0c;在不同的生命周期方法中&#xff0c;开发人员可以执行不同的操作&#xff0c;例如初始化状态、数据加载、渲染、更新等。一个组件的生命周期…

C# 使用递归方法实现汉诺塔步数计算

C# 使用递归方法实现汉诺塔步数计算 Part 1 什么是递归Part 2 汉诺塔Part 3 程序 Part 1 什么是递归 举一个例子&#xff1a;计算从 1 到 x 的总和 public int SumFrom1ToX(int x) {if(x 1){return 1;}else{int result x SumFrom1ToX_2(x - 1); // 调用自己return result…

Vim学习(四)——命令使用技巧

命令模式 打开文本默认模式&#xff0c;按**【ESC】**重新进入 【/关键字】&#xff1a;搜索匹配关键字 G&#xff1a;最后一行 gg&#xff1a;第一行 hjkl:左下右上 yy: 复制一行 dd&#xff1a;删除一行 p:粘贴 u: 撤销插入模式 按**【i / a / o】**键均可进入文本编辑模式…

2023年国赛 高教社杯数学建模思路 - 案例:异常检测

文章目录 赛题思路一、简介 -- 关于异常检测异常检测监督学习 二、异常检测算法2. 箱线图分析3. 基于距离/密度4. 基于划分思想 建模资料 赛题思路 &#xff08;赛题出来以后第一时间在CSDN分享&#xff09; https://blog.csdn.net/dc_sinor?typeblog 一、简介 – 关于异常…

uniapp 回退到指定页面 保存页面状态

uniapp 历史页面回退到指定页面。 getCurrentPages() 内容如下 let delta getCurrentPages().reverse().findIndex(item > item.route "pages/popularScience/daodi") if(delta-1){uni.navigateTo({url: /pages/popularScience/daodi,success: res > {},fa…

Python编程基础-文件的打开和读取

文件的访问 使用 open() 函数 打开文件 &#xff0c;返回一个 file 对象 使用 file 对象的读 / 写方法对文件进行读 / 写的 操作 使用 file 对象的 close() 方法关闭文件 打开文件 open()方法&#xff0c;需要一个字符串路径&#xff0c;并返回一个文件对象&#xff0c;默认是”…

2023年国赛数学建模思路 - 案例:退火算法

文章目录 1 退火算法原理1.1 物理背景1.2 背后的数学模型 2 退火算法实现2.1 算法流程2.2算法实现 建模资料 ## 0 赛题思路 &#xff08;赛题出来以后第一时间在CSDN分享&#xff09; https://blog.csdn.net/dc_sinor?typeblog 1 退火算法原理 1.1 物理背景 在热力学上&a…

【分享】华为设备登录安全配置案例

微思网络www.xmws.cn&#xff0c;2002年成立&#xff0c;专业IT认证培训21年&#xff0c;面向全国招生&#xff01; 微 信 号 咨 询&#xff1a; xmws-IT 华为HCIA试听课程&#xff1a;超级实用&#xff0c;华为VRP系统文件详解【视频教学】华为VRP系统文件详解 华为HCIA试听课…

原生轮播图的实现

<!DOCTYPE html> <html lang"en"><head><meta charset"UTF-8"><meta name"viewport" content"widthdevice-width, initial-scale1.0"><title>轮播图</title><style>* {margin: 0;pad…

WGS84地球坐标系,GCJ02火星坐标系,BD09百度坐标系简介与转换 资料收集

野火 ATGM332D简介 高性能、低功耗 GPS、北斗双模定位模块 STM32 GPS定位_为了维护世界和平_的博客-CSDN博客 秉火多功能调试助手上位机开源&#xff01;共六款软件&#xff0c;学到你吐... , - 电脑上位机 - 野火电子论坛 - Powered by Discuz! https://www.firebbs.cn/for…

jenkins 是什么?

一、jenkins 是什么&#xff1f; Jenkins是一个开源的、提供友好操作界面的持续集成(CI)工具&#xff0c;起源于Hudson&#xff0c;主要用于持续、自动的构建/测试软件项目、监控外部任务的运行。Jenkins用Java语言编写&#xff0c;可在Tomcat等流行的servlet容器中运行&#…

Tomcat线程池梳理

Tomcat梳理 文章目录 Tomcat梳理1.问题2.监控tomcat线程池springboot1.xspringboot2.x转为json格式打印输出 3.SpringBoot内置线程解析测试controlleryaml配置可知ThreadPoolExecutor有如下五种线程池状态。线程池监控指标并发测试并发请求数 < Tomcat最大线程数20并发请求数…

mysql并行效率提升

下面是一个并行读取mysql数据库表的测试程序&#xff0c;测试结果发现&#xff0c;读取10个表&#xff0c;1个个读取&#xff0c;和并行读取10个&#xff0c;效率一样&#xff0c;甚至并行读取还慢很多&#xff0c;这是为什么&#xff1f; con get_db_conn() results {} poo…

SV-7101T网络音频广播终端使用手册

1.1、产品简介 感谢你使用我司的SV-7101T网络音频播放终端&#xff0c;SV-7101T能处理tcp/ip网络音频流&#xff0c;提供一路线路输出。主要用于公共数字广播&#xff0c;媒体教学&#xff0c;报警等需要数字音频的领域。 SV-7101T具有10/100M以太网接口&#xff0c;支持最高4…

Linux 发行版 Debian 宣布支持龙芯 LoongArch 架构

近期&#xff0c;龙芯发布了 3A6000 桌面处理器&#xff0c;芯片的性能又一次大幅度提升&#xff0c;成为国产芯片的又一里程碑。 同期&#xff0c;LoongArch 架构的生态建设也迅速提升&#xff0c;开源网络引导固件 iPXE、QQ Linux 版、摩尔线程等软硬件都官宣支持龙芯 Loong…