总结:通过点击事件将输入的待办事项,简单的push、splice数组,来进行事项的添加与移除。
展望:增加一个时间选项,将时间-事项同时展示出来,并争取使用vueresource进行数据交互。
<template>
<div id="app">
<h1>ToDoList</h1>
<input type="text" v-model="addSomething"><button @click="add">提交</button>
<ul id="something">
<li v-for='(value,index) in list' :key=index @click="remove(index)">{{ index+1 }}.{{ value }}</li>
</ul>
</div>
</template>
<script>
export default {
name: 'App',
components: {
// HelloWorld
},
data(){
return{
addSomething:"",
selectTime:"",
list:[]
}
},
methods:{
add:function(){
this.list.push(this.addSomething);
this.addSomething='';
},
remove:function(index){
this.list.splice(index,1)
},
addTime:function(){
console.log(this.selectTime)
}
}
}
</script>
<style>
#app {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
list-style: none;
}
</style>