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. javascript - js輸入框限定字?jǐn)?shù)問題2. css - label文字居中3. MySQL中無法修改字段名的疑問4. python - 關(guān)于爬取網(wǎng)站,下載圖片的時候碰到網(wǎng)址結(jié)構(gòu)問題卡住5. pdo - mysql 簡單注入疑問6. html5 - H5實現(xiàn)微場景的思路是什么 環(huán)境怎么搭建 求大神幫忙帶路 有好的課程希望推薦一下7. javascript - vue項目里的package.json8. 為什么學(xué)習(xí)PHP9. javascript - table固定尾行,有人寫過嗎?10. 引入traits后,為什么index得是空的呢?
