<template>
<div id="app">
<h1 v-text="title"></h1>
<input v-model="newItem" v-on:keyup.enter="addNew">
<ul>
<li v-for="item in items" v-bind:class="{finished:item.isFinished}" v-on:click="toggleFinish(item)">
{{ item.label }}
</li>
</ul>
</div>
</template>
<script>
export default {
data () {
return {
title: 'roberto baggio!',
items: [{
label: 'aaa',
isFinished: true
},
{
label: 'bbb',
isFinished: false
}],
newItem: ''
}
},
methods: {
toggleFinish: function (item) {
item.isFinished= !item.isFinished
},
addNew: function(){
console.log("sss")
}
}
}
</script>
余人1