-
Notifications
You must be signed in to change notification settings - Fork 19
/
app.js
38 lines (37 loc) · 894 Bytes
/
app.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
Vue.createApp({
data() {
return {
valueInput: '',
needDoList: [],
completeList: []
};
},
methods: {
handleInput (event) {
this.valueInput = event.target.value;
},
addTask () {
if(this.valueInput === '') { return };
this.needDoList.push({
title: this.valueInput,
id: Math.random()
});
this.valueInput = '';
},
doCheck (index, type) {
if(type === 'need') {
const completeMask = this.needDoList.splice(index, 1);
this.completeList.push(...completeMask);
}
else {
const noCompleteMask = this.completeList.splice(index, 1);
this.needDoList.push(...noCompleteMask);
}
},
removeMask (index, type) {
const toDoList = type === 'need' ? this.needDoList : this.completeList;
toDoList.splice(index, 1);
}
}
}
).mount('#app');