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. flask+vue+webpack使用nginx+uwsgi部署問題2. javascript - 微信小程序picker為什么會變成兩行?3. objective-c - 同一個APP的微信登錄的微信開發平臺賬號和微信支付的微信開發平臺賬號可以是不同一個嗎?4. javascript - 百度echarts series數據更新問題5. css3 - [CSS] 動畫效果 3D翻轉bug6. html5 - Chrome訪問本地文件緩慢7. javascript - 微信音樂分享8. javascript - 我寫的href跳轉地址不是百度,為什么在有的機型上跳轉到百度了,有的機型跳轉正確9. html5 - H5移動端UC瀏覽器的,跳轉下一個頁面,下一個頁面input輸入框獲取焦點后,會帶出上一頁的內容?10. 在ios下 微信打開iframe鏈接的頁面時 在微信里長按無法識別二維碼
