54
54
:message =" toastMessage"
55
55
:type =" toastAlertType"
56
56
/>
57
- <div id =" kossie" >coder</div >
58
57
</template >
59
58
60
59
<script >
61
60
import { useRoute , useRouter } from ' vue-router' ;
62
61
import axios from ' axios' ;
63
- import { ref , computed , onBeforeMount , onMounted , onBeforeUpdate , onUpdated , onBeforeUnmount , onUnmounted } from ' vue' ;
62
+ import { ref , computed , onUnmounted } from ' vue' ;
64
63
import _ from ' lodash' ;
65
64
import Toast from ' @/components/Toast.vue' ;
66
65
@@ -69,27 +68,6 @@ export default {
69
68
Toast
70
69
},
71
70
setup () {
72
- onBeforeMount (() => {
73
- console .log (document .querySelector (' #kossie' ))
74
- });
75
- onMounted (() => {
76
- console .log (document .querySelector (' #kossie' ))
77
- });
78
- onBeforeUpdate (() => {
79
- console .log (' before updat' );
80
- })
81
-
82
- onUpdated (() => {
83
- console .log (' updated' )
84
- })
85
- onBeforeUnmount (() => {
86
- console .log (' before unmount' )
87
- })
88
-
89
- onUnmounted (() => {
90
- console .log (' unmounted' )
91
- })
92
- console .log (' hello' )
93
71
const route = useRoute ();
94
72
const router = useRouter ();
95
73
const todo = ref (null );
@@ -98,8 +76,13 @@ console.log(document.querySelector('#kossie'))
98
76
const showToast = ref (false );
99
77
const toastMessage = ref (' ' );
100
78
const toastAlertType = ref (' ' );
79
+ const timeout = ref (null );
101
80
const todoId = route .params .id
102
81
82
+ onUnmounted (() => {
83
+ clearTimeout (timeout .value );
84
+ })
85
+
103
86
const getTodo = async () => {
104
87
try {
105
88
const res = await axios .get (`
@@ -136,11 +119,11 @@ console.log(document.querySelector('#kossie'))
136
119
toastMessage .value = message;
137
120
toastAlertType .value = type;
138
121
showToast .value = true ;
139
- setTimeout (() => {
122
+ timeout . value = setTimeout (() => {
140
123
toastMessage .value = ' ' ;
141
124
toastAlertType .value = ' ' ;
142
125
showToast .value = false ;
143
- }, 3000 )
126
+ }, 5000 )
144
127
}
145
128
146
129
const onSave = async () => {
0 commit comments