-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
52 lines (51 loc) · 1.63 KB
/
index.html
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
49
50
51
52
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>Task Manager</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<body>
<div id="app">
<div class="container">
<div class="row">
<p>Add a task</p>
<input type="text" v-model="newTask" /><button v-on:click="addTask" v-on:keyup.enter="addTask">[ + ]</button>
</div>
<div class="row">
<p>You have {{countTask}} tasks</p>
<ul>
<li v-for="task in tasks">{{task}} <button v-on:click="removeTask($index)">[ - ]</button></li>
</ul>
</div>
</div>
</div>
<script src="http://cdnjs.cloudflare.com/ajax/libs/vue/1.0.26/vue.js"></script>
<script>
new Vue({
el: '#app',
data: {
countTask: 0,
newTask: '',
tasks: []
},
computed: {
countTask:function() {
return this.tasks.length
}
},
methods: {
addTask:function() {
if(this.newTask) {
this.tasks.push(this.newTask);
this.newTask = "";
}
},
removeTask:function(index) {
this.tasks.splice(index,1);
}
}
})
</script>
</body>
</html>