<template>
  <div class="hello">
    <h1>t-o-d-o-l-i-s-t</h1>
    <input v-model="inputValue"/>
    <button  @click="handleSubmit">提交</button>
    <h4>进行中</h4>
    <ul>
      <li v-for="(item,index) of list" :key="index">
        {{item}}
        <button  @click="handleFinish(index,0)">点击完成</button>
        <button @click="handleDelete(index,0)">点击删除</button>
      </li>
    </ul>
    <h4>已完成</h4>
    <ul id>
      <li v-for="(item,index) of list2" :key="index">
        {{item}}
        <button  @click="handleFinish(index,1)">恢复进行</button>
        <button @click="handleDelete(index,1)">点击删除</button>
      </li>
    </ul>
  </div>
</template>

 

<script>
export default {
  name: 'HelloWorld',
  data () {
    return {
      inputValue: '',
      list: [],
      list2:[],
    }
  },
  methods: {
    handleSubmit(){
        this.list.push(this.inputValue)
        this.inputValue = ''
    },
    handleFinish(index,n){
        if (n==0){
          this.list2.push(this.list[index])
            this.list.splice(index,1) 
        }        
        else if(n==1){
          this.list.push(this.list2[index])
          this.list2.splice(index,1)
        }
            
    },
    handleDelete(index,n){
      if (n==0){
         this.list.splice(index,1) 
      }            
      else if (n==1){
         this.list2.splice(index,1)
      }
          
    }
  }
}
</script>

 

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
div{
  height: 800px;
  background-color: rgb(172, 164, 161);
}

 

ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
</style>