前端重于积累,下次使用不迷路。
纯vue代码
话不多说,直接上效果图:

源码附上:

<template><div class="bgBody"><!--    卡片--><el-row :gutter="12" ><el-col :span="8" ><el-card shadow="hover" class="bgRow"><!--    电影清单    --><h2 style="margin-right: 200px;line-height: initial;"><strong style="font-weight: 10;color: #3f8b5c;">想看的电影:</strong><input style="background-color: rgb(75,76,82);border: none;border-radius: 5px;height: 20px;color: rgb(200,200,200)"type="text" v-model="inputValue" @keydown.enter="submit"></h2><h2 style="font-weight: 10;color: #b68a26; line-height: initial; margin-right: 410px">想看:({{noLength}})</h2><h3 class="xiangKan"><ul><li v-for="(item,index) in todoList" :key="index" v-show="!item.done"><input type="checkbox" @click.prevent="change(item,true)"><span v-if="index!=updateIndex" @dblclick="update(item,index)" style="font-weight: 10;">{{item.title}}</span><input v-if="index==updateIndex"type="text"v-model="item.title"@keydown.enter="updateSave"@keydown.esc="backData(item)"@blur="updateSave"v-focusstyle="background-color: rgb(75,76,82);border: none;border-radius: 5px;height: 20px;color: rgb(200,200,200)"><span class="del-btn" @click="del(index)">×</span></li></ul></h3><h2 style="font-weight: 10;color: #959595;line-height: initial; margin-right: 380px" >已看完:({{yesLength}})</h2><h3 class="yiKan"><ul ><li v-for="(item,index) in todoList" :key="index" v-show="item.done"><input type="checkbox" checked @click.prevent="change(item,false)"><span v-if="index!=updateIndex" @dblclick="update(item,index)"style="font-weight: 10;">{{item.title}}</span><input v-if="index==updateIndex"type="text"v-model="item.title"@keydown.enter="updateSave"@keydown.esc="backData(item)"@blur="updateSave"v-focusstyle="background-color: rgb(75,76,82);border: none;border-radius: 5px;height: 20px;color: rgb(200,200,200)"><span class="del-btn" @click="del(index)">×</span></li></ul></h3></el-card></el-col></el-row></div>
</template><script>
export default {name: "TODO",data() {return {inputValue: "", // 输入框的值todoList: [], // 数据updateIndex: -1, //要修改的元素下标tempValue: "" //临时保存信息的变量}},created() {// 初始化数据let todoList = localStorage.todoList;if (todoList) {this.todoList = JSON.parse(todoList)}},computed: {noLength() { // 计算未完成的元素长度let count = 0this.todoList.map(item => {if (!item.done) {count++}})return count},yesLength() { // 计算已完成的元素长度let count = 0this.todoList.map(item => {if (item.done) {count++}})return count}},methods: {submit() {// 提交this.todoList.push({title: this.inputValue,done: false})// 置空输入框this.inputValue = ""//同步this.save();},change(item, checked) {// 点击复选框,改变完成状态if (checked) {item.done = true} else {item.done = false}this.save();},update(item, index) {// 把元素的内容临时保存到一个变量中this.tempValue = item.title// 设置要修改元素的下标this.updateIndex = index},updateSave() {// 修改后保存this.save()// 还原数据this.updateIndex = -1this.tempValue = ""},backData(item) {// 按esc键还原,设置当前元素的内容为保存的临时变量值item.title = this.tempValue// 清除要修改的元素下标this.updateIndex = -1// 清除临时变量this.tempValue = ""},del(index) {// 根据下标删除元素this.todoList.splice(index, 1)this.save()},save() {//同步数据localStorage.todoList = JSON.stringify(this.todoList)}},directives: { // 自定义指令focus: {inserted(el) {el.focus()}}}}
</script><style scoped>
.del-btn{margin-left:20px;font-size:16px;color:red;cursor:pointer;
}
.xiagnKan ul{list-style: none;padding: 0;margin: 0;color: rgb(130,130,130);
}
.xiangKan ul li{line-height: 30px;color:darkgoldenrod;
}
.yiKan ul{list-style: none;padding: 0;margin: 0;color: rgb(130,130,130);
}
.yiKan ul li{line-height: 30px;color: rgb(130,130,130);
}
.bgRow{background: rgb(45,46,52);border: none;
}
.bgBody div{margin-left: calc(50% - 300px);
}
</style>

More than a favor for you!
对你何止一句钟意。

vue编写to-do list源码相关推荐

  1. 基于SpringBoot vue的电脑商城平台源码和论文含支付宝沙箱支付

    演示视频: 基于SpringBoot vue的电脑商城平台源码和论文含支付宝沙箱支付演示视频 支付宝沙箱: package com.java.controller;import java.util.* ...

  2. java计算机毕业设计vue.js开发红酒网站源码+mysql数据库+系统+lw文档+部署

    java计算机毕业设计vue.js开发红酒网站源码+mysql数据库+系统+lw文档+部署 java计算机毕业设计vue.js开发红酒网站源码+mysql数据库+系统+lw文档+部署 本源码技术栈: ...

  3. java计算机毕业设计基于springboot+vue+elementUI的旅游网站(源码+数据库+Lw文档)

    项目介绍 旅游管理平台采用B/S模式,促进了旅游管理平台的安全.快捷.高效的发展.传统的管理模式还处于手工处理阶段,管理效率极低,随着用户的不断增多,传统基于手工管理模式已经无法满足当前用户需求,随着 ...

  4. java计算机毕业设计vue校园菜鸟驿站管理系统源码+数据库+系统+lw文档

    java计算机毕业设计vue校园菜鸟驿站管理系统源码+数据库+系统+lw文档 java计算机毕业设计vue校园菜鸟驿站管理系统源码+数据库+系统+lw文档 本源码技术栈: 项目架构:B/S架构 开发语 ...

  5. 基于springboot vue新生可视化报到管理系统源码

    演示视频: 基于springboot vue新生可视化报到管理系统源码 package com.zxy.controller;import com.baomidou.mybatisplus.exten ...

  6. vue+django 微博舆情系统源码、深度学习+舆情扩散消失分析、舆情紧急等级、属地分析、按话题、情感预测、话题评论获取、提取观点、正面负面舆情、按区域检测舆情

    项目背景 315又马上要到了,现在有开始对食品安全话题的关注地提升了,因此,本文系统对微博的食品安全话题进行分析,有如下的功能 1.展示当前食品安全事件相关的热点信息以及提供根据食品关键词,食品安全类 ...

  7. C++基础升华:编写的中国象棋源码

    VC++编写的中国象棋源码,支持悔棋功能,而且我觉得这象棋的智商相当高,玩了下竟然每次都输,可能我象棋水平太菜.本游戏源代码开源,在VC6.0下可顺利编译,游戏可选择难易程序,运行界面也挺友好. 项目 ...

  8. 计算机毕业设计基于springboot+vue+elementUI的网吧管理系统(源码+系统+mysql数据库+Lw文档)

    项目介绍 随着我国的经济发展,人们的生活水平也有了一定程度的提高,对网络的要求也越来越高,很多家庭都有了自己的电脑,但是很多时候大家在家里玩电脑的时候找不到那种玩耍的气氛和氛围,这个时候大家就都选择了 ...

  9. 计算机毕业设计springboot基于vue众筹平台系统 aj3l6源码+系统+程序+lw文档+部署

    计算机毕业设计springboot基于vue众筹平台系统 aj3l6源码+系统+程序+lw文档+部署 计算机毕业设计springboot基于vue众筹平台系统 aj3l6源码+系统+程序+lw文档+部 ...

  10. java计算机毕业设计Vue社区蔬果商城源码+mysql数据库+系统+lw文档+部署

    java计算机毕业设计Vue社区蔬果商城源码+mysql数据库+系统+lw文档+部署 java计算机毕业设计Vue社区蔬果商城源码+mysql数据库+系统+lw文档+部署 本源码技术栈: 项目架构:B ...

最新文章

  1. python输入与输出165
  2. 2015快捷键在哪里设置_炒股软件的选择通达信软件的基本设置
  3. 【l转】VS2015下解决:无法解析的外部符号 __imp___vsnprintf 及__iob_func
  4. LOJ P10149 凸多边形的划分 题解
  5. Nginx_location配置讲解
  6. easyVMAF:在自然环境下运行VMAF
  7. 20220201--CTF刷题MISC方向--第4题
  8. AMD GPU+VS2010的OpenCL配置
  9. C#方法的参数 Ref Out Params 4种类型的参数
  10. Apache RewriteCond %{REQUEST_FILENAME} 不起作用问题
  11. -bash: unzip: 未找到命令_29 条运维工程师必会实用 Linux 命令
  12. Linux向文件中写入内容
  13. js调用打印机直接打印_打印机如何打印二维码
  14. Curl 方式实现POST提交数据
  15. asp.net 实现动态显示当前时间(不用javascript不考虑开销)
  16. TCP/IP 三次握手
  17. 安全技巧:映像劫持与反劫持技术
  18. 2020年终系列:国内区块链专利授权总数不足3000项|链塔智库
  19. remap_pfn_range()详解
  20. Python 3.11 ,即将变得更快!

热门文章

  1. mysql添加新的实例_MySQL中添加新用户权限的实例详解
  2. 从源码角度分析下 micrometer 自定义 metrics endpoint 和 springboot actuator
  3. Mysql数据库查询当前操作的数据库名
  4. MyEclipse2015双击不能打开文件
  5. Mac电脑 hbuilderx 运行到小程序node-sass异常
  6. Android之Junit测试类
  7. 微信 手机 网站 开发 签名 signature node (在更新中)
  8. oracle 10g 报错:ORA-00257: archiver error. Connect internal only, until freed
  9. 在保护继承中基类的共有成员_C#初学者教程系列11:继承
  10. lm358在哪个库里_库里8和aj35哪个好 库里8是安德玛的吗