Vue
by Roland Doda
HTML
<div id="app">
<transition-group name="fade">
<div v-for="(todo,index) in todos" :key="todo.text" @click="deleteItem(index)">
{{ todo.text}}
</div>
</transition-group>
</div>
CSS
body {
background: #20262E;
padding: 20px;
font-family: Helvetica;
}
#app {
background: #fff;
border-radius: 4px;
padding: 20px;
transition: all 0.2s;
}
div {
background: blue;
padding: 10px;
margin-top: 10px;
cursor: pointer;
}
.fade-leave-active {
transition: all 1s;
}
.fade-leave-to {
opacity: 0;
}
Vue
new Vue({
el: "#app",
data: {
todos: [
{ text: "Learn JavaScript", done: false },
{ text: "Learn Vue", done: false },
{ text: "Play around in JSFiddle", done: true },
{ text: "Build something awesome", done: true }
]
},
methods: {
deleteItem(index) {
this.todos.splice(index, 1);
}
}
})