Skip to content

Commit 005e637

Browse files
committed
Added check box to mark task as completed, for this a style.css file is also added for styling
1 parent 83960a4 commit 005e637

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

app.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,18 @@ const app = Vue.createApp({
55
return {
66
newTodo: '',
77
todos :[
8-
{id: ++id, text: 'Try new app in Vue'},
9-
{id: ++id, text: 'Learn Actix Web'}
8+
{id: ++id, text: 'Try new app in Vue',done:true},
9+
{id: ++id, text: 'Learn Actix Web',done:true},
10+
{id: ++id, text: 'Learn Rust Programming',done:false},
11+
{id: ++id, text: 'Learn Sanskrit',done:false},
12+
{id: ++id, text: 'Learn Vedas',done:false},
1013
]
1114

1215
}
1316
},
1417
methods: {
1518
addTodo() {
16-
this.todos.push({id: ++id, text: this.newTodo})
19+
this.todos.push({id: ++id, text: this.newTodo,done:false})
1720
this.newTodo='';
1821
},
1922

index.html

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,19 @@
44
<meta charset="UTF-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
66
<title>Simple Vue Js ToDo UI</title>
7+
<link rel="stylesheet" href="style.css">
78
<script src="https://unpkg.com/vue@3"></script>
89
</head>
910
<body>
11+
<h1>Simple To Do List in Vue-JS 3</h1>
1012
<div id="app">
1113

1214
<input v-model="newTodo"></input>
1315
<button @click="addTodo()">Add Task</button>
1416
<ul>
1517
<li v-for="todo in todos" :key="todo.id">
16-
{{ todo.text }}
18+
<input type="checkbox" v-model="todo.done">
19+
<span :class="{ completed: todo.done }">{{ todo.text }}</span>
1720
<button @click="removeTodo(todo)">Remove</button>
1821
</li>
1922
</ul>

style.css

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
body{
2+
margin:0 auto;
3+
background-color: beige;
4+
color:black;
5+
padding: 20px;
6+
}
7+
.completed{
8+
text-decoration: line-through;
9+
}

0 commit comments

Comments
 (0)