VUE todolist

本文介绍了一个使用Vue.js构建的简单待办事项应用程序。该应用包括输入框用于添加待办事项,按钮用于提交,以及一个事项列表可以显示所有已添加的待办事项并提供删除功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<template>
  <div>
    <div>
      <input v-model="inputValue"/>
      <button @click="handelpush">push</button>
    </div>
    <ul>
      <todo-item
        v-for="(item,index) of list"
        :key="index"
        :content="item"
        :index="index"
        @delete="handelDelete"
      ></todo-item>
    </ul>
  </div>
</template>

<script>
  import todoItem from './components/todoItem'

  export default {
    components: {
      'todo-item': todoItem
    },
    data() {
      return {
        inputValue: '',
        list: []
      }
    },
    methods: {
      handelpush() {
        this.list.push(this.inputValue),
          this.inputValue = ''
      },
      handelDelete(index) {
        this.list.splice('index', 1)
      }
    }
  }
</script>

<style>

</style>
<template>
  <li @click="handelDelete">{{content}}</li>
</template>

<script>
  export default {
    props: ['content', 'index'],
    methods: {
      handelDelete() {
        this.$emit('delete', this.index)
        // alert("dasdfasd");
      }

    }
  }
</script>

<style scoped>

</style>
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import todoList from './todoList'

Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  el: '#app',
  components: {todoList},
  template: '<todoList/>'
})

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值