vue todoList

<template>

  <div id="app">

  <div class="mato">

      <input type="text" class="mato_input" oninput = "value=value.replace(/[\u4E00-\u9FA5]/g,'')" placeholder="吃饭睡觉打豆豆" v-model="inputValue">

      <button @click="add" class="mato_add">add</button>

      <ul class="mato_ul">

        <li v-for="(item,index) of totolist" :key="index">

          <input type="checkbox">        

          <label>{{item}}</label>

          <label @click="del" class="ft">x</label>

        </li>

      </ul>

    </div>

     </template>

export default {

  name: 'App',

  data(){

    return{

      inputValue:'',

      totolist:[]

    }

  },

  methods:{

    add:function(){

       this.totolist.push(this.inputValue);

       this.inputValue = '';//清空input的值

 

    },

    del:function(key){

        this.totolist.splice(key, 1);//splice方法删除对应下标

    }

  }

}

</script>

*{margin: 0;padding:0;}

.ft{float:right;margin-right: 20px;cursor: pointer;}

a{text-decoration:none;color:#000;}

ul,li{list-style: none;}

.finished{

  text-decoration: line-through;

}

.mato{width:500px;height:200px;margin:0 auto;margin-top: 80px;background-color: #231f1f;display:table;}

.mato_input{

  width:430px;

  height:30px;

  outline: none;

  border:none;

  padding-left: 20px;

}

.mato_add{

  width:42px;

  height:30px;

  margin-left: 4px;

  background-color: #fff;

  border:none;

  cursor:pointer;

  outline:none;

}

.mato_ul li{

  color:#fff;

  line-height: 1.8;

  border-bottom:solid 1px #fff;

  cursor:pointer;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值