vue--day59---集成第三方动画
1. 加载 第三方动画
npm install aninate.css
2. App.vue
<template>
<div>
<button @click="isShow=!isShow">
显示/隐藏
</button>
<transition-group appear
name="animate__animated animate__bounce"
enter-active-class="animate__swing"
leave-active-class="animate__backOutUp"
>
<h1 v-show="!isShow" key="1">kkkk史满意</h1>
<h1 v-show="isShow" key="2">kkkSMY</h1>
</transition-group>
</div>
</template>
<script>
import 'animate.css';
export default{
name:'Test3',
data(){
return {
isShow:true
}
}
}
</script>
<style scoped>
h1{
background-color: orangered;
}
</style>
2. Test.vue
<template>
<div>
<button @click="isShow=!isShow">
显示/隐藏
</button>
<transition name="hello" appear>
<h1 v-show="isShow" >你好呀</h1>
</transition>
</div>
</template>
<script>
export default{
name:'Test',
data(){
return {
isShow:true
}
}
}
</script>
<style scoped>
h1{
background-color: orangered;
}
.hello-enter-active{
animation: ceshi 1s linear;
}
.hello-leave-active{
animation: ceshi 1s linear reverse;
}
@keyframes ceshi {
from{
transform: translateX(-100%);
}
to{
transform: translateX(0px);
}
}
</style>
4. Test2.vue
<template>
<div>
<button @click="isShow=!isShow">
显示/隐藏
</button>
<transition-group name="hello" appear>
<h1 v-show="!isShow" key="1">史满意</h1>
<h1 v-show="isShow" key="2">SMY</h1>
</transition-group>
</div>
</template>
<script>
export default{
name:'Test2',
data(){
return {
isShow:true
}
}
}
</script>
<style scoped>
h1{
background-color: orangered;
/* transition:1s linear; */
}
/* 进入的起点 离开的终点 */
.hello-enter,.hello-leave-to{
transform: translateX(-100%);
}
.hello-enter-active,.hello-leave-active{
transition:1s linear;
}
/* 进入的终点 离开的起点 */
.hello-enter-to,.hello-leave{
transform: translateX(0);
}
</style>
5. Test3.vue
<template>
<div>
<button @click="isShow=!isShow">
显示/隐藏
</button>
<transition-group appear
name="animate__animated animate__bounce"
enter-active-class="animate__swing"
leave-active-class="animate__backOutUp"
>
<h1 v-show="!isShow" key="1">kkkk史满意</h1>
<h1 v-show="isShow" key="2">kkkSMY</h1>
</transition-group>
</div>
</template>
<script>
import 'animate.css';
export default{
name:'Test3',
data(){
return {
isShow:true
}
}
}
</script>
<style scoped>
h1{
background-color: orangered;
}
</style>