File tree Expand file tree Collapse file tree 4 files changed +52
-37
lines changed Expand file tree Collapse file tree 4 files changed +52
-37
lines changed Original file line number Diff line number Diff line change 32
32
},
33
33
{
34
34
"subject" : " f" ,
35
- "completed" : false ,
35
+ "completed" : true ,
36
36
"id" : 13
37
37
},
38
38
{
39
39
"subject" : " a" ,
40
- "completed" : false ,
40
+ "completed" : true ,
41
41
"id" : 14
42
42
},
43
43
{
44
44
"subject" : " 12" ,
45
- "completed" : false ,
45
+ "completed" : true ,
46
46
"id" : 15
47
47
},
48
48
{
49
49
"subject" : " 123" ,
50
- "completed" : false ,
50
+ "completed" : true ,
51
51
"id" : 16
52
52
},
53
53
{
54
54
"subject" : " 1234" ,
55
- "completed" : true ,
56
- "id" : 17
57
- },
58
- {
59
- "subject" : " 12345" ,
60
55
"completed" : false ,
61
- "id" : 18
62
- },
63
- {
64
- "subject" : " new todo222" ,
65
- "completed" : true ,
66
- "id" : 21
56
+ "id" : 17
67
57
}
68
58
]
69
59
}
Original file line number Diff line number Diff line change 1
1
<template >
2
2
<Modal >
3
- <template v-slot : title >
3
+ <template # title >
4
4
Delete Todo
5
5
</template >
6
- <template v-slot : body >
6
+ <template # body >
7
7
Are you sure you want to delete this todo?
8
8
</template >
9
- <template v-slot : footer >
9
+ <template # footer >
10
10
<button
11
11
type =" button"
12
12
class =" btn btn-secondary"
Original file line number Diff line number Diff line change
1
+ <template >
2
+ <div
3
+ v-for =" (item, index) in items"
4
+ :key =" item.id"
5
+ class =" card mt-2"
6
+ >
7
+ <slot :item =" item" :index =" index" ></slot >
8
+ </div >
9
+ </template >
10
+
11
+ <script >
12
+ export default {
13
+ props: {
14
+ items: {
15
+ type: Array ,
16
+ required: true
17
+ }
18
+ }
19
+ }
20
+ </script >
21
+
22
+ <style >
23
+
24
+ </style >
Original file line number Diff line number Diff line change 1
1
<template >
2
- <div
3
- v-for =" (todo, index) in todos"
4
- :key =" todo.id"
5
- class =" card mt-2"
6
- >
2
+ <List :items =" todos" >
3
+ <template #default =" { item , index } " >
7
4
<div
8
5
class =" card-body p-2 d-flex align-items-center"
9
6
style =" cursor : pointer "
10
- @click =" moveToPage(todo .id)"
7
+ @click =" moveToPage(item .id)"
11
8
>
12
9
<div class =" flex-grow-1" >
13
10
<input
14
11
class =" ml-2 mr-2"
15
12
type =" checkbox"
16
- :checked =" todo .completed"
13
+ :checked =" item .completed"
17
14
@change =" toggleTodo(index, $event)"
18
15
@click.stop
19
16
>
20
- <span :class =" { todo: todo .completed }" >
21
- {{ todo .subject }}
17
+ <span :class =" { todo: item .completed }" >
18
+ {{ item .subject }}
22
19
</span >
23
20
</div >
24
21
<div >
25
22
<button
26
23
class =" btn btn-danger btn-sm"
27
- @click.stop =" openModal(todo .id)"
24
+ @click.stop =" openModal(item .id)"
28
25
>
29
26
Delete
30
27
</button >
31
28
</div >
32
29
</div >
33
- </div >
34
- <teleport to =" #modal" >
35
- <Modal
36
- v-if =" showModal"
37
- @close =" closeModal"
38
- @delete =" deleteTodo"
39
- />
40
- </teleport >
30
+ </template >
31
+ </List >
32
+
33
+ <teleport to =" #modal" >
34
+ <Modal
35
+ v-if =" showModal"
36
+ @close =" closeModal"
37
+ @delete =" deleteTodo"
38
+ />
39
+ </teleport >
41
40
</template >
42
41
43
42
<script >
44
43
import { useRouter } from ' vue-router' ;
45
44
import Modal from ' @/components/DeleteModal.vue' ;
46
45
import { ref } from ' vue' ;
46
+ import List from ' @/components/List.vue' ;
47
47
48
48
export default {
49
49
components: {
50
- Modal
50
+ Modal,
51
+ List
51
52
},
52
53
props: {
53
54
todos: {
You can’t perform that action at this time.
0 commit comments