本文實例為大家分享了vue實現循環(huán)切換動畫的具體代碼,供大家參考,具體內容如下
注意動畫的鉤子函數的判斷邏輯,注意動畫編寫時類名的順序!!
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>vue</title> <style> .box{ width: 200px; height: 200px; background-color: red; } .guo-enter-active,.guo-leave-active{ width: 200px; height: 200px; opacity: 1; background-color: red; transition: 0.7s; } .guo-leave-to{ width: 100px; height: 100px; opacity: 0; background-color: orange; } .guo-enter{ width: 100px; height: 100px; opacity: 0; background-color: orange; } .box2{ margin-top: 100px; } </style> <script src='vue.min.js'></script> </head> <body> <div id='app'> <div> <input type="button" value='change' @click='change'> <transition name='guo' @after-enter='Enter' @after-leave='Leave'> <div v-show='show' class='box'></div> </transition> <transition name='guo' @enter='Enter2' @after-leave='Leave2'> <div v-show='show2' class='box box2'></div> </transition> </div> </div> <script> new Vue({ el:'#app', data:{ show:false, show2:false }, methods:{ change(){ this.show = !this.show; }, Enter(){ this.show2 = true; }, Leave(){ this.show2=false; }, Leave2(){ this.show = true; }, Enter2(){ this.show = false; } } }); </script> </body> </html>
另外有需要云服務器可以了解下創(chuàng)新互聯scvps.cn,海內外云服務器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務器、裸金屬服務器、高防服務器、香港服務器、美國服務器、虛擬主機、免備案服務器”等云主機租用服務以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應用場景需求。
新聞名稱:vue實現循環(huán)切換動畫-創(chuàng)新互聯
本文鏈接:http://chinadenli.net/article36/decipg.html
成都網站建設公司_創(chuàng)新互聯,為您提供品牌網站建設、網站策劃、網站制作、企業(yè)網站制作、網站建設、網站改版
聲明:本網站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯