File tree Expand file tree Collapse file tree 4 files changed +32
-15
lines changed Expand file tree Collapse file tree 4 files changed +32
-15
lines changed Original file line number Diff line number Diff line change 60
60
"completed" : false ,
61
61
"id" : 18
62
62
},
63
- {
64
- "subject" : " 123456" ,
65
- "completed" : false ,
66
- "id" : 19
67
- },
68
- {
69
- "subject" : " 21" ,
70
- "completed" : true ,
71
- "id" : 20
72
- },
73
63
{
74
64
"subject" : " new todo" ,
75
65
"completed" : true ,
Original file line number Diff line number Diff line change 12
12
</li >
13
13
</ul >
14
14
</nav >
15
- <router-view />
15
+ <div class =" container" >
16
+ <router-view />
17
+ </div >
16
18
</template >
17
19
18
20
<script >
Original file line number Diff line number Diff line change 1
1
<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 >
3
13
</template >
4
14
5
15
<script >
6
16
import { useRoute } from ' vue-router' ;
17
+ import axios from ' axios' ;
18
+ import { ref } from ' @vue/reactivity' ;
7
19
8
20
export default {
9
21
setup () {
10
22
const route = useRoute ();
23
+ const todo = ref (null );
24
+ const loading = ref (true );
11
25
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
+ };
13
39
}
14
40
}
15
41
</script >
Original file line number Diff line number Diff line change 1
1
<template >
2
- <router-view />
3
- <div class =" container" >
2
+ <div >
4
3
<h2 >To-Do List</h2 >
5
4
<input
6
5
class =" form-control"
You can’t perform that action at this time.
0 commit comments