javascript - vue 動畫過渡 手風琴
問題描述
為什么實現不了手風琴?
<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就像養了一只寵物一樣,把它養在水族箱里。 </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就像養了一只寵物一樣,把它養在水族箱里。 </p></transition> </p> <script>new Vue({ el: '#app', data: {detail: false }}); </script></body></html>
相關文章:
1. mysql - 分庫分表、分區、讀寫分離 這些都是用在什么場景下 ,會帶來哪些效率或者其他方面的好處2. 視頻文件不能播放,怎么辦?3. node.js - nodejs開發中常用的連接mysql的庫4. python bottle跑起來以后,定時執行的任務為什么每次都重復(多)執行一次?5. mysql - 把一個表中的數據count更新到另一個表里?6. 請教使用PDO連接MSSQL數據庫插入是亂碼問題?7. mysql 查詢身份證號字段值有效的數據8. python - 爬蟲模擬登錄后,爬取csdn后臺文章列表遇到的問題9. visual-studio - Python OpenCV: 奇怪的自動補全問題10. Python爬蟲如何爬取span和span中間的內容并分別存入字典里?
