<!DOCTYPE?html> <html> <head> ????<title></title> ????<meta?http-equiv="Content-Type"?content="text/html;?charset=utf-8"?/> ????<link?rel="stylesheet"?type="text/css"?href="./animate.css"> ????<script?src="./vue.js"></script> ????<!--?<script?src="http://cdn.staticfile.org/vue/2.6.10/vue.common.dev.js"></script>?--> ???? </head> <body> ????<div?id="root"> ????????//性能考慮,盡量不用index作為key值?<br> ????????<div?v-for="(item)?of?list"?:key="item.id"> ????????????{{item.title}} ????????</div> ????????<button?@click="handBtnClick">add</button> ????</div> ????<script?type="text/javascript"> ????????var?count?=?0; ????????var?vm?=?new?Vue({ ????????????el:?"#root", ????????????data:?{ ????????????????list:?[] ????????????}, ????????????methods:?{ ????????????????handBtnClick:?function()?{ ????????????????????this.list.push({ ????????????????????????id:?count++, ????????????????????????title:?"hello" ????????????????????}); ????????????????} ????????????} ????????}); ????</script> </body> </html>
之前是對(duì)單個(gè)或多個(gè)元素之間做切換動(dòng)畫效果,現(xiàn)在,對(duì)一個(gè)列表過渡效果,用標(biāo)簽<transition-group>:
創(chuàng)新互聯(lián)專注于海滄企業(yè)網(wǎng)站建設(shè),成都響應(yīng)式網(wǎng)站建設(shè)公司,商城網(wǎng)站制作。海滄網(wǎng)站建設(shè)公司,為海滄等地區(qū)提供建站服務(wù)。全流程按需定制制作,專業(yè)設(shè)計(jì),全程項(xiàng)目跟蹤,創(chuàng)新互聯(lián)專業(yè)和態(tài)度為您提供的服務(wù)
<!DOCTYPE?html> <html> <head> ????<title></title> ????<meta?http-equiv="Content-Type"?content="text/html;?charset=utf-8"?/> ????<link?rel="stylesheet"?type="text/css"?href="./animate.css"> ????<script?src="./vue.js"></script> ????<!--?<script?src="http://cdn.staticfile.org/vue/2.6.10/vue.common.dev.js"></script>?--> ????<style?type="text/css"> ????????/*因?yàn)闆]有給它命名,所以用默認(rèn)v開頭的class名*/ ????????.v-enter,?.v-leave-to?{ ????????????opacity:?0; ????????} ????????.v-enter-active,?.v-leave-active?{ ????????????transition:?opacity?1s; ????????} ????</style> </head> <body> ????<div?id="root"> ????????//性能考慮,盡量不用index作為key值?<br> ????????<transition-group> ????????????<div?v-for="(item)?of?list"?:key="item.id"> ????????????????{{item.title}} ????????????</div> ????????</transition-group> ????????<button?@click="handBtnClick">add</button> ????</div> ????<script?type="text/javascript"> ????????var?count?=?0; ????????var?vm?=?new?Vue({ ????????????el:?"#root", ????????????data:?{ ????????????????list:?[] ????????????}, ????????????methods:?{ ????????????????handBtnClick:?function()?{ ????????????????????this.list.push({ ????????????????????????id:?count++, ????????????????????????title:?"hello" ????????????????????}); ????????????????} ????????????} ????????}); ????</script> </body> </html>
為啥上面的效果是增加的都有漸顯效果呢?
用一對(duì)<transition-group>標(biāo)簽包裹
<transition-group>
????<div>hello</div>
????<div>hello</div>
????<div>hello</div>
</transition-group>
相當(dāng)于每一個(gè)都用一對(duì)<transition>標(biāo)簽包裹
<transition>
????<div>hello</div>
</transition>
<transition>
????<div>hello</div>
</transition>
<transition>
????<div>hello</div>
</transition>
當(dāng)前標(biāo)題:Vue中的列表過渡
網(wǎng)站鏈接:http://aaarwkj.com/article40/jeeeho.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站導(dǎo)航、品牌網(wǎng)站建設(shè)、微信小程序、搜索引擎優(yōu)化、自適應(yīng)網(wǎng)站、電子商務(wù)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)