<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Hello World</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="app">
<!--给列表每一项都增加过渡动画-->
<!-- <transition-group> -->
<div v-for="item of list" :key="item.id">
{{item.title}}
</div>
</transition-group>
<button @click="handleBtnClick">Add</button>
</div>
<script>
var count = 0;
var app = new Vue({
el: '#app',
data: {
list: []
},
methods: {
handleBtnClick: function() {
this.list.push({
id: count++,
title: 'hello world'
})
}
}
})
</script>
</body>
</html>
给列表每一项都增加过渡动画
最新推荐文章于 2023-11-22 18:05:08 发布