深入理解Vue的過度與動畫
1.在插入、更新、移除DOM元素時,在合適的時候給元素添加樣式類名
2.元素有一個進入過程:Enter,一個離開過程Leave。
兩個過程都有一個初始態(tài)()和終止態(tài)(-to)和兩態(tài)之間的過度效果(activate)

3.寫法

動畫:寫好v-enter-active(替換come這個名字)和v-leave-active(替換go)(這兩個是vue的工作)和動畫atguigu(這個是css3的效果)。再用<transition>把動畫元素包起來就行。appear是讓元素一加載就執(zhí)行一次v-enter-activate


過度:這里的起點終點是vue的作用。

或者

<style scoped>
/* .todo-enter-active{
animation: myAnamite 1s;
}
.todo-leave-active{
animation: myAnamite 1s reverse;
}
@keyframes myAnamite {
from{
transform: translateX(-100%);
}
to{
transform: translateX(0);
}
} */
.todo-enter,.todo-leave-to{
transform: translateX(-100%);
}
.todo-leave,.todo-enter-to{
transform: translateX(0);
}
.todo-enter-active,.todo-leave-active{
transition: 1s linear;
}
</style>
多個元素過度:

第三方動畫庫:anamite.css庫
安裝:

引入:在script中 import ‘animate.css'

總結
本篇文章就到這里了,希望能夠給你帶來幫助,也希望您能夠多多關注腳本之家的更多內容!

