Skip to content

Commit b3b837a

Browse files
committed
48
1 parent df01cb7 commit b3b837a

File tree

4 files changed

+32
-15
lines changed

4 files changed

+32
-15
lines changed

db.json

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,6 @@
6060
"completed": false,
6161
"id": 18
6262
},
63-
{
64-
"subject": "123456",
65-
"completed": false,
66-
"id": 19
67-
},
68-
{
69-
"subject": "21",
70-
"completed": true,
71-
"id": 20
72-
},
7363
{
7464
"subject": "new todo",
7565
"completed": true,

src/App.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
</li>
1313
</ul>
1414
</nav>
15-
<router-view/>
15+
<div class="container">
16+
<router-view/>
17+
</div>
1618
</template>
1719

1820
<script>

src/pages/todos/_id.vue

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,41 @@
11
<template>
2-
<div>Todo Page</div>
2+
<h1>To-Do Page</h1>
3+
<div v-if="loading">
4+
Loading..
5+
</div>
6+
<form v-else>
7+
<div class="form-group">
8+
<label>Todo Subject</label>
9+
<input v-model="todo.subject" type="text" class="form-control">
10+
</div>
11+
<button class="btn btn-primary">Save</button>
12+
</form>
313
</template>
414

515
<script>
616
import { useRoute } from 'vue-router';
17+
import axios from 'axios';
18+
import { ref } from '@vue/reactivity';
719
820
export default {
921
setup() {
1022
const route = useRoute();
23+
const todo = ref(null);
24+
const loading = ref(true);
1125
12-
console.log(route.params.id);
26+
const getTodo = async () => {
27+
const res = await axios.get('http://localhost:3000/todos/' + route.params.id);
28+
29+
todo.value = res.data;
30+
loading.value = false;
31+
};
32+
33+
getTodo();
34+
35+
return {
36+
todo,
37+
loading,
38+
};
1339
}
1440
}
1541
</script>

src/pages/todos/index.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<template>
2-
<router-view/>
3-
<div class="container">
2+
<div>
43
<h2>To-Do List</h2>
54
<input
65
class="form-control"

0 commit comments

Comments
 (0)