Vue中的列表过渡
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Vue中的列表过渡</title> <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> <style type="text/css"> .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}}————{{item}} </div> </transition-group> <button @click="handleBtnClick">Add</button> </div> <script type="text/javascript"> let count = 0 var rm = new Vue({ el: '#root', data: { list: [] }, methods: { handleBtnClick() { this.list.push({ id: count++, title: 'Harold' }) } } }) </script> </body> </html>
略懂,略懂....