1<template>
2 {{ timerCount }}
3</template>
4
5<script>
6
7 export default {
8
9 data() {
10 return {
11 timerCount: 30
12 }
13 },
14
15 watch: {
16
17 timerCount: {
18 handler(value) {
19
20 if (value > 0) {
21 setTimeout(() => {
22 this.timerCount--;
23 }, 1000);
24 }
25
26 },
27 immediate: true // This ensures the watcher is triggered upon creation
28 }
29
30 }
31 }
32
33</script>