vue實(shí)現(xiàn)頁面刷新動(dòng)畫
本文實(shí)例為大家分享了vue實(shí)現(xiàn)頁面刷新動(dòng)畫的具體代碼,供大家參考,具體內(nèi)容如下
做一個(gè)vue的頁面刷新動(dòng)畫,找了好多動(dòng)畫樣式,感謝大佬們?cè)斓妮喿印?/p>
主要就是在index.html文件里面寫一個(gè)動(dòng)畫樣式,在頁面刷新的時(shí)候讓他去前面做動(dòng)畫,等我們的樣式可以加載的時(shí)候去把這個(gè)動(dòng)畫樣式給移除掉就可以了,而判斷我們的樣式是否加載好可以用created生命周期去判斷,因?yàn)檫@個(gè)生命周期是在瀏覽器解析完html的各種樣式后觸發(fā)的,所以可以在app.vue的created生命周期里面把動(dòng)畫樣式移除
接下來是代碼
index.html里面的代碼
css樣式:
<style type="text/css" scoped="scoped"> ?? ??? ?html,body { ?? ??? ??? ?width: 100%; ?? ??? ??? ?height: 100%; ?? ??? ??? ?padding: 0; ?? ??? ??? ?margin: 0; ?? ??? ??? ?background: cornflowerblue; ?? ??? ?} ?? ??? ? ?? ??? ?.loadings{ ?? ??? ??? ?width: 100%; ?? ??? ??? ?height: 100%; ?? ??? ??? ?display: flex; ?? ??? ??? ?justify-content: center; ?? ??? ??? ?align-items: center; ?? ??? ?} ?? ??? ? ?? ??? ?.spinner { ?? ??? ??? ?width: 300px; ?? ??? ??? ?height: 50px; ?? ??? ??? ?position: relative; ?? ??? ??? ?display: flex; ?? ??? ??? ?justify-content: center; ?? ??? ??? ?align-items: center; ?? ??? ?} ?? ??? ?.spinner > div { ?? ??? ? ?width: 30px; ?? ??? ? ?height: 30px; ?? ??? ? ?background-color: #67CF22; ?? ??? ?? ?? ??? ? ?border-radius: 100%; ?? ??? ? ?margin: 0px 10px; ?? ??? ? ?display: inline-block; ?? ??? ? ?-webkit-animation: bouncedelay 1.4s infinite ease-in-out; ?? ??? ? ?animation: bouncedelay 1.4s infinite ease-in-out; ?? ??? ? ?/* Prevent first frame from flickering when animation starts */ ?? ??? ? ?-webkit-animation-fill-mode: both; ?? ??? ? ?animation-fill-mode: both; ?? ??? ?} ?? ??? ?? ?? ??? ?.spinner .bounce1 { ?? ??? ? ?-webkit-animation-delay: -0.32s; ?? ??? ? ?animation-delay: -0.32s; ?? ??? ?} ?? ??? ?? ?? ??? ?.spinner .bounce2 { ?? ??? ? ?-webkit-animation-delay: -0.16s; ?? ??? ? ?animation-delay: -0.16s; ?? ??? ?} ?? ??? ?? ?? ??? ?@-webkit-keyframes bouncedelay { ?? ??? ? ?0%, 80%, 100% { -webkit-transform: scale(0.0) } ?? ??? ? ?40% { -webkit-transform: scale(1.0) } ?? ??? ?} ?? ??? ?? ?? ??? ?@keyframes bouncedelay { ?? ??? ? ?0%, 80%, 100% { ?? ??? ? ? ?transform: scale(0.0); ?? ??? ? ? ?-webkit-transform: scale(0.0); ?? ??? ? ?} 40% { ?? ??? ? ? ?transform: scale(1.0); ?? ??? ? ? ?-webkit-transform: scale(1.0); ?? ??? ? ?} ?? ??? ?} ?? ??? ? ?? ??? ?#app{ ?? ??? ??? ?display: none; ?? ??? ?} </style>
html代碼
<body> ?? ??? ?<div class="loadings"> ?? ??? ??? ?<div class="spinner"> ?? ??? ??? ? ?<div class="bounce1"></div> ?? ??? ??? ? ?<div class="bounce2"></div> ?? ??? ??? ? ?<div class="bounce3"></div> ?? ??? ??? ?</div> ?? ??? ?</div> ?? ??? ?<div id="app"></div> </body>
下面是app.vue的代碼
<script> ?? ?export default { ?? ??? ?name: 'App', ?? ??? ?data() { ?? ??? ??? ?return { ?? ??? ??? ? ?? ??? ??? ?} ?? ??? ?}, ?? ??? ?created() { ?? ??? ?//判斷有沒有動(dòng)畫的盒子在,在的話移除掉 ?? ??? ??? ?let loading = document.getElementsByClassName('loadings')[0] ?? ??? ??? ?if(loading){ ?? ??? ??? ??? ?document.body.removeChild(loading) ?? ??? ??? ?} ?? ??? ?} ?? ?} </script> <style lang="less"> ?? ?body{ ?? ??? ?background: white;//這里是把動(dòng)畫影響的背景顏色改回來 ?? ?} ?? ?#app{ ?? ??? ?width: 100%; ?? ??? ?height: 100%; ?? ??? ?display: block; ?? ??? ?//這里是把隱藏的app盒子展示出來 ?? ?} </style>
這就是所有的頁面刷新動(dòng)畫的代碼了
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
element step組件在另一側(cè)加時(shí)間軸顯示
本文主要介紹了element step組件在另一側(cè)加時(shí)間軸顯示,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2022-06-06vue實(shí)現(xiàn)移動(dòng)端懸浮窗效果
這篇文章主要為大家詳細(xì)介紹了vue實(shí)現(xiàn)移動(dòng)端懸浮窗效果,vuejs實(shí)現(xiàn)div拖拽移動(dòng),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-12-12vue+element-ui實(shí)現(xiàn)表格編輯的三種實(shí)現(xiàn)方式
這篇文章主要介紹了vue+element-ui實(shí)現(xiàn)表格編輯的三種實(shí)現(xiàn)方式,主要有表格內(nèi)部顯示和編輯切換,通過彈出另外一個(gè)表格編輯和直接通過樣式控制三種方式,感興趣的小伙伴們可以參考一下2018-10-10Vue入門之?dāng)?shù)量加減運(yùn)算操作示例
這篇文章主要介紹了Vue入門之?dāng)?shù)量加減運(yùn)算操作,結(jié)合實(shí)例形式分析了vue.js基本數(shù)值運(yùn)算相關(guān)操作技巧,需要的朋友可以參考下2018-12-12el-form 多層級(jí)表單的實(shí)現(xiàn)示例
這篇文章主要介紹了el-form 多層級(jí)表單的實(shí)現(xiàn)示例,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-09-09vue2.0 和 animate.css的結(jié)合使用
animate.css是一款前端動(dòng)畫庫,相似的有velocity-animate。這篇文章給大家介紹vue2.0 和 animate.css的結(jié)合使用,需要的朋友參考下吧2017-12-12vue項(xiàng)目實(shí)現(xiàn)登陸注冊(cè)效果
這篇文章主要為大家詳細(xì)介紹了vue項(xiàng)目實(shí)現(xiàn)登陸注冊(cè)效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-09-09