vue写的简单版todolist

本文介绍了一个使用Vue.js构建的简单待办事项应用程序。该应用允许用户输入任务并将其添加到列表中,同时提供了删除任务的功能。通过这个示例,展示了Vue.js的基本用法,包括数据绑定、事件处理和列表渲染。

上一张丑图:

clipboard.png

项目演示地址:http://47.75.195.199/todolist/
源码地址:https://github.com/chunsenye/...

<template>
  <div>
    <label >今天要做什么</label>
    <input type="text" v-model="text">
    <input type="button" value="提交" @click="submit">
    <ul>
      <li v-for="(item,index) in todolist" :key="index">
        {{index+1}}.{{item}}
        <input type="button" value='X' @click="deleteT(index)" :key="index">  
      </li>
    </ul>
  </div>
 
</template>

<script>
export default {
  name: "HelloWorld",
  data() {
    return {
      msg: "Welcome to Your Vue.js App",
      todolist: ["code to die", "never mind", "say goodbye"],
      text:''
    };
  },
  methods: {
    submit() {
      this.todolist.push(this.text);
      this.text='';
    },
    deleteT(index) {
      this.todolist.splice(index,1);
    }
  }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h1,
h2 {
  font-weight: normal;
}
ul li {
  padding: 10px;
  font-size: 26px;
  list-style: none;
}

a {
  color: #42b983;
}
</style>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值