当前位置:网站首页>什么是动画效果?什么是过渡效果?
什么是动画效果?什么是过渡效果?
2022-07-27 02:48:00 【刘家奕_】
目录
动画效果
首先动画效果
这定义大家应该都明白吧,我也不好怎么说。
先来个效果图(不晓得搞动态效果先这样看吧)

代码
直接来代码吧........

组件Studnet.vue的代码为:
<template>
<div>
<button @click="isShow = !isShow">显示和隐藏</button>
<transition name="hello" appear>
<h1 v-show="isShow">你好呀</h1>
</transition>
</div>
</template>
<script>
export default {
name: "Student",
data() {
return {
isShow: true,
};
},
};
</script>
<style scoped>
h1 {
background-color: yellow;
}
.hello-enter-active {
animation: liujiayi 0.5s linear;
}
.hello-leave-active {
/* animation: liujiayi 0.5s reverse linear; */
animation: liujiayi 0.5s linear reverse;
}
@keyframes liujiayi {
from {
transform: translateX(-100%);
}
to {
transform: translateX(0px);
}
}
</style>
下面来分别介绍

每一个name都是独一无二的,如果写了name的话,下面的代码应该这样写

没写的话,直接统一

appear的话就是

请自行百度,它的完整写法是 :appear="true" 别忘了前面的:
过渡效果
和动画效果是效果显示是一样的
代码:
话不多说,上代码

Student2.vue代码如下:
<template>
<div>
<button @click="isShow = !isShow">显示和隐藏</button>
<transition name="hello" appear>
<h1 v-show="isShow">你好呀</h1>
</transition>
</div>
</template>
<script>
export default {
name: "Student2",
data() {
return {
isShow: true,
};
},
};
</script>
<style>
h1 {
background-color: yellow;
transition: 0.5s linear;
}
/* 进入的起点 */
.hello-enter {
transform: translateX(-100%);
}
/* 进入的终点 */
.hello-enter-to {
transform: translateX(0px);
}
/* 离开的起点 */
.hello-leave {
transform: translateX(0px);
}
/* 离开的终点 */
.hello-leave-to {
transform: translateX(-100%);
}
</style>
介绍:
这里------------------->

是其中一种写法,另一种写法为:

用哪个看自己喜欢
多个元素过渡(transition-group)
<transition-group name="hello" appear>
<h1 v-show="isShow" key="1">你好呀</h1>
<h1 v-show="!isShow" key="2">刘家奕</h1>
</transition-group>一定要写key
边栏推荐
- 基于风能转换系统的非线性优化跟踪控制(Matlab代码实现)
- Principle understanding and application of hash table and consistent hash
- Restful fast request 2022.2.2 release, supporting batch export of documents
- Restful Fast Request 2022.2.2发布,支持批量导出文档
- 零基础小白也能懂的 Redis 数据库,手把手教你易学易用!
- ZJCTF_ login
- 阿里云服务器域名加端口网页不能访问问题记录
- 科目三: 济南章丘五号线
- 288页18万字智能化校园总体设计 目录
- Function pointer and callback function
猜你喜欢

科目三: 济南章丘五号线

C. Cypher

STM32CubeMX学习笔记(41)——ETH接口+LwIP协议栈使用(DHCP)

The fifth strong network cup national network security challenge Title reappearance (with title attachment, detailed explanation)

Programming implementation of eight queens

线上一个隐匿 Bug 的复盘

Kettle reads file split by line

Smart pointer shared_ ptr、unique_ ptr、weak_ ptr

VR全景人淘金“小心机”(上)

基于风能转换系统的非线性优化跟踪控制(Matlab代码实现)
随机推荐
Smart pointer shared_ ptr、unique_ ptr、weak_ ptr
Detailed tutorial of typera
Application of one-dimensional array
04. Detailed steps for installing the simulated browser chromedriver in Google browser
222. 完全二叉树的节点个数
3381. 手机键盘(清华大学考研机试题)
暑假加餐|有钱人和你想的不一样(第5天)+电力系统潮流仿真(文档和Matlab代码)
Have you encountered the situation that CDC reads incomplete MySQL fields? How to deal with it?
C # using sqlsugar updatable system to report invalid numbers, how to solve it? Ask for guidance!
安装umi4阻碍一天的问题解决了
[Android synopsis] kotlin multithreaded programming (I)
科目三: 济南章丘6号线
Chapter 5 决策树和随机森林实践
Using redis C library, the problem of asynchronous memory leakage
flinkSQLclient创建的job,flink重启就没了,有什么办法吗?
Share the current life -- a six week internship experience of a high school graduate in CCTV
Process analysis of object creation
回归测试:意义、挑战、最佳实践和工具
Interview question: the difference between three instantiated objects in string class
Realization of regular hexagon map with two-dimensional array of unity