-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
41 lines (40 loc) · 937 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
new Vue({
el: '#app',
data: {
items: [],
item: '',
title: 'Click to add',
},
computed: {
empty() {
if(!this.items.length) {
return true
}
}
},
methods : {
addItem() {
if(!this.item) {
alert('Pls Add Something!!');
} else {
this.items.push({task :this.item, done: false});
this.item = '';
localStorage.setItem("Memory",JSON.stringify(this.items));
}
},
changeDone(e) {
var index = e.target.dataset.no;
this.items[index].done = !(this.items[index].done);
localStorage.setItem("Memory",JSON.stringify(this.items));
},
delet(e) {
var index = e.target.dataset.no;
console.log(index);
this.items.splice(index,1);
localStorage.setItem("Memory",JSON.stringify(this.items));
}
},
mounted: function() {
this.items = JSON.parse(localStorage.getItem("Memory")) || [];
}
});