<div id="app">
<input type="text" v-model="inputValue" /> <input type="button" @click="addTodo" value="确定" />
<ul>
<li @click="deleteMe(index)" v-for="(item, index) of todoList">{{item}}</li>
</ul>
</div>
<script>
new Vue({
el:'#app',
data:{
todoList:['first todo','sec todo'],
inputValue:""
},
methods:{
addTodo:function(){ //添加
this.todoList.push(this.inputValue);
this.inputValue="";
},
deleteMe:function(index){ //删除
this.todoList.splice(index,1);
}
}
})
</script>