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. javascript - [js]為什么畫布里不出現圖片呢?在線等2. sql語句 - mysql中關聯表查詢問題3. javascript - 如何將一個div始終固定在某個位置;無論屏幕和分辨率怎么變化;div位置始終不變4. html5 - 有可以一次性把所有 css外部樣式轉為html標簽內style=" "的方法嗎?5. javascript - vscode alt+shift+f 格式化js代碼,通不過eslint的代碼風格檢查怎么辦。。。6. html - vue項目中用到了elementUI問題7. javascript - 有什么比較好的網頁版shell前端組件?8. javascript - iframe 為什么加載網頁的時候滾動條這樣顯示?9. javascript - 求解答:實例對象調用constructor,此時constructor內的this的指向?10. javascript - 原生canvas中如何獲取到觸摸事件的canvas內坐標?
