当前位置:网站首页>什么是动画效果?什么是过渡效果?
什么是动画效果?什么是过渡效果?
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
边栏推荐
猜你喜欢

NFT数字藏品系统开发:老牌文学杂志玩起新潮数字藏品

Feitengtengrui d2000 won the "top ten hard core technologies" award of Digital China

「Gonna Be Alright 会好的」数藏现已开售!感受艺术家的心灵共鸣

C#怎么实现给Word每一页设置不同文字水印

Is Jiufang intelligent investment a regular company? Talk about Jiufang intelligent investment

SkyWalking分布式系统应用程序性能监控工具-中

Okaleido tiger is about to log in to binance NFT in the second round, which has aroused heated discussion in the community

H.265网页播放器EasyPlayer对外开放录像的方法

On the first day of Shenzhen furniture exhibition, the three highlights of Jin Ke'er booth were unlocked!

The fifth strong network cup national network security challenge Title reappearance (with title attachment, detailed explanation)
随机推荐
452页13万字现代智慧乡镇雪亮工程整体解决方案2022版
C. Cypher
电商系统结合商品秒杀活动,VR全景不断带来收益
222. Number of nodes of complete binary tree
Chapter 5 决策树和随机森林实践
Golang发送邮件库email
PSINS工具箱中轨迹生成工具详细解析
flink cdc 到MySQL8没问题,到MySQL5读有问题,怎么办?
flinkSQLclient创建的job,flink重启就没了,有什么办法吗?
回归测试:意义、挑战、最佳实践和工具
C# 使用SqlSugar Updateable系统报错无效数字,如何解决?求指导!
Lixia action | Yuanqi Digitalization: existing mode or open source innovation?
Message queue learning -- Concepts
C # using sqlsugar updatable system to report invalid numbers, how to solve it? Ask for guidance!
Will this flinkcdc monitor all tables in the database? Or the designated table? I look at the background log. It monitors all tables. If it monitors
Smart pointer shared_ ptr、unique_ ptr、weak_ ptr
Day 28 of leetcode
零基础小白也能懂的 Redis 数据库,手把手教你易学易用!
Detailed tutorial of typera
分析一下CSDN大佬写的CAS,可重入锁, 非公平锁