javascript - vue 動畫過渡 手風(fēng)琴
問題描述
為什么實現(xiàn)不了手風(fēng)琴?
<style> .collapse-enter{max-height: 0; } .collapse-enter-active {max-height: 10rem;-webkit-transition: all .3s cubic-bezier(1.0, 0.5, 0.8, 1.0);transition: all .3s cubic-bezier(1.0, 0.5, 0.8, 1.0); } .collapse-leave {max-height: 10rem; } .collapse-leave-active {max-height: 0;-webkit-transition: all .3s cubic-bezier(1.0, 0.5, 0.8, 1.0);transition: all .3s cubic-bezier(1.0, 0.5, 0.8, 1.0); }</style><h1 @click='detail = !detail'>Title</h1><transition name='collapse'> <p v-show='detail'>在紐約長島的一家餐吧里有一只132歲的大龍蝦。這只紐約最老的龍蝦名叫Louie,重22磅(約20斤),20年來,它一直生活在一家餐吧里,餐吧主人Butch Yamali就像養(yǎng)了一只寵物一樣,把它養(yǎng)在水族箱里。 </p></transition>data: { detail: false,}
問題解答
回答1:不知道你這里的是不是就是完整的代碼了,我對你的代碼稍作修改之后就能正常運行了。代碼的邏輯和CSS樣式寫得沒有問題。如果上面就是你的完整代碼,那上面的錯誤在于,你沒有掛載實例。
<!DOCTYPE html><html lang='en'><head> <meta charset='UTF-8'> <title>collapse</title> <script src='http://cdn.staticfile.org/vue/2.0.3/vue.js'></script> <style>.collapse-enter{ max-height: 0;}.collapse-enter-active { max-height: 10rem; -webkit-transition: all .3s cubic-bezier(1.0, 0.5, 0.8, 1.0); transition: all .3s cubic-bezier(1.0, 0.5, 0.8, 1.0);}.collapse-leave { max-height: 10rem;}.collapse-leave-active { max-height: 0; -webkit-transition: all .3s cubic-bezier(1.0, 0.5, 0.8, 1.0); transition: all .3s cubic-bezier(1.0, 0.5, 0.8, 1.0);} </style></head><body> <p id='app'><h1 @click='detail = !detail'>Title</h1><transition name='collapse'> <p v-show='detail'>在紐約長島的一家餐吧里有一只132歲的大龍蝦。這只紐約最老的龍蝦名叫Louie,重22磅(約20斤),20年來,它一直生活在一家餐吧里,餐吧主人Butch Yamali就像養(yǎng)了一只寵物一樣,把它養(yǎng)在水族箱里。 </p></transition> </p> <script>new Vue({ el: '#app', data: {detail: false }}); </script></body></html>
相關(guān)文章:
1. angular.js - 輸入郵箱地址之后, 如何使其自動在末尾添加分號?2. javascript - 后臺管理系統(tǒng)左側(cè)折疊導(dǎo)航欄數(shù)據(jù)較多,怎么樣直接通過搜索去定位到具體某一個菜單項位置,并展開當(dāng)前菜單3. 如何解決docker宿主機無法訪問容器中的服務(wù)?4. javascript - Web微信聊天輸入框解決方案5. javascript - 如何使用nodejs 將.html 文件轉(zhuǎn)化成canvas6. python - Scrapy存在內(nèi)存泄漏的問題。7. 如何用筆記本上的apache做微信開發(fā)的服務(wù)器8. CSS3 畫如下圖形9. angular.js - $stateChangeSuccess事件在狀態(tài)跳轉(zhuǎn)的時候不執(zhí)行?10. android - rxjava merge 返回Object對象數(shù)據(jù)如何緩存
