ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
~~~ <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Vue中的列表过渡</title> <script src="vue.js"></script> <style> .v-enter, .v-leave-to { opacity: 0; } .v-enter-active, .v-leave-active { transition: opacity 1s; } </style> </head> <body> <div id="root"> <transition-group> <div v-for="(item,index) of list" :key="item.id">{{item.title}}</div> </transition-group> <button @click="handleBtnClick">Add</button> </div> <script> // var count = 0; var vm = new Vue({ el: '#root', data: { list: [], count: 0, }, methods: { handleBtnClick() { this.list.push({ id: this.count++, title: 'hello world' }) } } }) </script> </body> </html> ~~~