【IMWeb训练营作业】---Todolist---

时间有点紧,样式没时间调了,功能都完善了,先放上来,回头把样式调好


调试好的效果图


html

<!DOCTYPE html >
< html lang= "en" >

< head >
< meta charset= "utf-8" >
< title >任务计划表 </ title >
< style >
body {
margin: 0;
font-family: Microsoft Yahei;
background: #f5f8fb;
}
</ style >
< link rel= "stylesheet" href= "style.css" >
< script src= "vue.js" ></ script >
</ head >

< body >
< div class= "app" >
< h3 class= "bit-title" >添加任务: </ h3 >
< input placeholder= "提示回车可添加任务" class= "task-input" type= "text" v-model= "todo"
v-on:keyup. enter= "addTodo" />
< ul class= "task-count" v-show= "list.length" >
< li >{{noCheckedLength}}任务未完成
</ li >
< li class= "action" >
< a class= "active" href= "#all" >所有任务 </ a >
< a href= "#unfinshed" >未完成的任务 </ a >
< a href= "#finshed" >完成的任务 </ a >
</ li >
</ ul >
< h3 class= "big-title" >任务列表: </ h3 >
< div class= "tasks" >
< span class= "no-task-tip" v-show= "!list.length" >还没有添加任何任务> </ span >
< ul class= "todo-list" >
< li class= "todo" : class= "{completed:item.isChecked,editing:item===edtorTodos}" v-for= "item in filteredList" >
< div class= "view" >
< input class= "toggle" type= "checkbox" v-model= "item.isChecked" />
< label @ dbclick= "edtorTodo(item)" >{{item.title}} </ label >
< button class= "destroy" @ click= "deleteTodo(item)" ></ button >
</ div >
< input v-focus= "edtorTodos=== item" class= "edit" type= "text" v-model= "item.title" @ blur= "edtorTodoed(item)" @ keyup. enter= "edtorTodoed(item)" @ keyup. esc= "cancelTodo(item)" />
</ li >
</ ul >
</ div >
< script src= "/app.js" ></ script >
</ body >
</ html >


app.js

var store = {
save( key, value) {
localStorage. setItem( key, JSON. stringify( value))
},
fetch( key) {
return JSON. parse( localStorage. getItem( key)) || [];
}
}
var filter = {
all: function ( list) {
return list;
},
unfinshed: function ( list) {
return list. filter( function ( item) {
return ! item. isChecked;
})
},
finshed: function ( list) {
return list. filter( function ( item) {
return item. isChecked;
})
}
}
//var list = [ ];
var list = store. fetch( 'todoList');
var vm = new Vue({
el: ".app",
data: {
list: list,
todo: "",
edtorTodos: "", //记录正在编辑的todo
beforeTitle: "",
visibility: "all",
},
watch: {
list: {
handler: function () {
store. save( 'todoList', this. list);
},
deep: true
}
},
computed: {
noCheckedLength: function () {
return this. list. filter( function ( item) {
return ! item. isChecked
}). length
},
filteredList: function () {

return filter[ this. visibility]? filter[ this. visibility]( list) : list;
}
},
methods: { //所有的事件处理函数
addTodo( ev) { //添加任务 es6
this. list. push({
title: this. todo,
isChecked: false
})
this. todo = '';
},
deleteTodo( todo, ev) {
var index = this. list. indexOf( todo);
this. list. splice( index, 1);
},
edtorTodo( todo) {
console. log( todo);
this. beforeTitle = todo. title;
this. edtorTodos = todo;
},
edtorTodoed( todo) {
this. edtorTodos = '';
},
cancelTodo( todo) {
console. log( 123)
todo. title = this. beforeTitle;
this. beforeTitle = "";
this. edtorTodos = ""
}
},
directives: {
"focus" : {
update( el, binding) {
if ( binding. value) {
el. focus();
}
}
}
}
});

function watchHashChange() {
var hash = window. location. hash. slice( 1);
console. log( hash);
vm. visibility = hash;
}
watchHashChange();
window. addEventListener( "hashchange", watchHashChange)



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在Node.js中,你可以使用内置的crypto模块来实现HMAC-SHA256算法。下面是一个示例代码: ```javascript const crypto = require('crypto'); const secret = 'Secret_Key'; const message = 'timestampGET/users/self/verify'; const hmac = crypto.createHmac('sha256', secret); hmac.update(message); const sign = hmac.digest('base64'); console.log(sign); ``` 在这个示例中,我们首先引入了crypto模块。然后,我们定义了密钥(secret)和要加密的消息(message)。接下来,我们使用createHmac方法创建了一个HMAC对象,并指定了算法为SHA256,并传入密钥。然后,我们使用update方法将消息传入HMAC对象进行更新。最后,我们使用digest方法以base64编码格式输出加密后的签名。 请注意,这个示例中的密钥和消息只是示意用法,你需要根据实际情况替换为你自己的密钥和消息。 #### 引用[.reference_title] - *1* [Typescript/Nodejs 使用HmacSHA256 & Base64对接口调用签名](https://blog.csdn.net/HumorChen99/article/details/117548951)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v4^insert_chatgpt"}} ] [.reference_item] - *2* [Hmac SHA256 加密在原生 Java 及 Node.js 的实现](https://blog.csdn.net/frgod/article/details/122025192)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v4^insert_chatgpt"}} ] [.reference_item] - *3* [腾讯IMWeb团队是如何使用 NodeJS 实现 JWT 原理](https://blog.csdn.net/lunahaijiao/article/details/109881868)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v4^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值