-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathscript.js
More file actions
48 lines (38 loc) · 1.08 KB
/
script.js
File metadata and controls
48 lines (38 loc) · 1.08 KB
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
42
43
44
45
46
47
48
const App = {
data() {
return {
// object
works: 'APP WORKS',
task: '',
completed: false,
todoList: [],
completedList: []
}
},
methods: {
addTodo() {
const newTask = this.task
const todoList = this.todoList
todoList.push(newTask)
},
removeTodo(todo) {
const todoList = this.todoList
const todoIndex = todoList.indexOf(todo)
todoList.splice(todoIndex, 1)
},
completeTodo(todo) {
const todoList = this.todoList
const todoIndex = todoList.indexOf(todo)
const completedList = this.completedList
completedList.push(todo)
todoList.splice(todoIndex, 1)
},
removeCompleted(todo) {
const completedList = this.completedList
const todoIndex = completedList.indexOf(todo)
completedList.splice(todoIndex, 1)
}
}
}
const app = Vue.createApp(App)
app.mount('#app')