vue js count down timer

Solutions on MaxInterview for vue js count down timer by the best coders in the world

showing results for - "vue js count down timer"
Salomé
07 Aug 2020
1<template>
2   {{ countDown }}
3</template>
4
5<script>
6    export default {
7        data() {
8            return {
9                countDown : 10
10            }
11        },
12        method: {
13            countDownTimer() {
14                if(this.countDown > 0) {
15                    setTimeout(() => {
16                        this.countDown -= 1
17                        this.countDownTimer()
18                    }, 1000)
19                }
20            }
21        }
22        created: {
23           this.countDownTimer()
24        }
25    }
26</script>
27
Sofie
14 Apr 2019
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>
Hanna
04 Aug 2018
1<template>
2  <div>
3    <slot :hour="hour" :min="min" :sec="sec"></slot>
4  </div>
5</template>
6
7<script>
8export default {
9  props : {
10    endDate : {  // pass date object till when you want to run the timer
11      type : Date,
12      default(){
13        return new Date()
14      }
15    },
16    negative : {  // optional, should countdown after 0 to negative
17      type : Boolean,
18      default : false
19    }
20  },
21  data(){
22    return{
23      now : new Date(),
24      timer : null
25    }
26  },
27  computed:{
28    hour(){
29      let h = Math.trunc((this.endDate - this.now) / 1000 / 3600);
30      return h>9?h:'0'+h;
31    },
32    min(){
33      let m = Math.trunc((this.endDate - this.now) / 1000 / 60) % 60;
34      return m>9?m:'0'+m;
35    },
36    sec(){
37      let s = Math.trunc((this.endDate - this.now)/1000) % 60
38      return s>9?s:'0'+s;
39    }
40  },
41  watch : {
42    endDate : {
43      immediate : true,
44      handler(newVal){
45        if(this.timer){
46          clearInterval(this.timer)
47        }
48        this.timer = setInterval(()=>{
49          this.now = new Date()
50          if(this.negative)
51            return
52          if(this.now > newVal){
53            this.now = newVal
54            this.$emit('endTime')
55            clearInterval(this.timer)
56          }
57        }, 1000)
58      }
59    }
60  },
61  beforeDestroy(){
62    clearInterval(this.timer)
63  }
64}
65</script>
66
Rogelio
03 Jan 2021
1<template>
2    {{ timerCount }}
3</template>
4
5<script>
6
7    export default {
8
9        data() {
10            return {
11                timerEnabled: true,
12                timerCount: 30
13            }
14        },
15
16        watch: {
17
18            timerEnabled(value) {
19                if (value) {
20                    setTimeout(() => {
21                        this.timerCount--;
22                    }, 1000);
23                }
24            },
25
26            timerCount: {
27                handler(value) {
28
29                    if (value > 0 && this.timerEnabled) {
30                        setTimeout(() => {
31                            this.timerCount--;
32                        }, 1000);
33                    }
34
35                },
36                immediate: true // This ensures the watcher is triggered upon creation
37            }
38
39        }
40
41        methods: {
42
43            play() {
44                this.timerEnabled = true;
45            },
46
47            pause() {
48                this.timerEnabled = false;
49            }
50
51        }
52
53    }
54
55</script>
56
Yannick
28 Nov 2016
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>
34
queries leading to this page
vue js timer not workingvue js time count downvuejs countdown examplecountdown timer 5min vue jstimer in vuejsvue timer count back secondvue js countdown v modelvue component timercountdown minut with vue jscountdown minutes vuevue day countdowncreate seconds countdown vuecraeting a timer in vuevue countdown timer end textvue countdown timer accuratevue js show countdown on the button label that indicateshow to create timer in vuevue countdown for vue js 2 in loopvuejs time countdown vue js timer count upvue countdown npmvue js countdownbuild a countdown expiry date timer in vue 3countdown event in vue tutorialadding countdown timer vuetifycountdown timer vue componenthow to do countdown min in vue jscount up timer vuemake countdown with vuevuejs show countdown timershow timer with vue jsvue 60 second countdown timervue props timer to secondsvuejs run on timertimer in vuetifycount down time vue jsvuejs timerfor n in countdown in vue jscountdown vue jshow to get countdown with vue jsvue countdown timer secondssimple countdown vuecountdown from date in vue jsvuejs countdown time alervuejs time countdown timervuejs 2 hours countdownvue js listen to countdownmaking a count down timer with vuevue js count down timertimer clock vue js 22vue 3 22 displaying a countdown timertimer count down vue js examplevue js timer functionsimple countdown timer with vue 2vue countdown till datevuejs countdown tutorialcountdown js vuecountdown with date vuejscreasting a timer in vuecountdown page vuejsvue listen to countdowncreating a timer in vue timer start vuevuetify create countdown timer formhow to get countdown in vue jsvue timer minute countdownvue js countdown timervue countdown vue 2vue countdown to datevuetify countdown timervue js timer examplevue js countdown time dates get from servervuejs clock countdownvue countdown timer 27how to make a countdown timer in vuestopwatch timer in vuetifycountdown timer tutorial vuejscountdown webworker vuecountdown minute vuevue live timervuejs countdown timer examplevuejs timer countdown1 hour countdown timer vue jscountdown timer vuetifystart a timer vuevue countdown timer npmcountdown till data vuevuejs show timercountdown timer in vue jsvue date countdown timervue js input countdown timervue countdown for vue 2vue countdown timervue countdown timer npmsimple time counter vue jsjs date countdown with vuesjscount timer in vue jsidle vue timer startvue show timercountdown timer vuevuejs count down timervuejs run timerget countdown timer minute vue jsvue periodic timer with countdowncountdown timer 3 minutes to 0 seconds vuejsvue countdown and callbackhow to make vue js timer countercreate timer in vuejsbuild a countdown timer in vuevue 3 countdown 5 minutesvue timer examplevuejs countdown timercount down in vuedraft countdown vuemake a vuejs timervue js timer on loadvue on finished countdownvue js countdownd10 second timer vuevue js countdown datecountdown vuejs based on datecreating a countdown timer in vuejsvue2 countdown timerdisplay timer in vuehow to make a timer in vuevue countdown timer codepencountdown timer button vuevue countdown animationvue js countdown from datecountdown timer in vuejsvuejs show countdown timer vuexcountdown using vuevuex countdown seconds create timer vuevue countdown formatvue start timervue countdown componentusing countdownjs woth vuevuejs timer examplevue display timercount down in vue jscountdown timer vue jscount down vuejscountdown in vue jsvue date countdown componenthow to get revers countdown vue jsvue2 date countdownvue date countdown vue 3 countdown timer five minutesvue timer countdownnpm vue countdowncountdown timer vue tutorialhow to create a timer in vuehow to write timer on vueminutes cutown timer vue jscountdown timer using vue jstimer countdown vuejsvuetify 1 hour tinercreate countdown in vue jsvue minutes countdown timerhow to do countdown in vue jsvue js timerhow to get count down in vue jsjquery countdown vuejsa minute countdown javascript vuevue js sync timer countdownvuejs time downvue countdown for vue js 2countdown vuejsvue timervuejs countdownvue countdown yearvue js countdown timervuetify countdown timer min and secondscountdown by simple minutes vue 3vue countdown destroyedvue countdown v bind countervue countdown clockhow to make countdown timer in vuecountdown timer vuejsvuejs countdown componenthow to countdown in vue jsvue clock timervuejs countdown time alertvue countdown timer componentcountdown minutes vuejsvue expiration countdown timervue countdown timervue count down timervue2 countdowncount down timer vuejsvue digital countdownvuejs set timer countdownvuejs simple timervue flip countdown timerjquery countdown in vue jsvue 3 countdown timervue js timertimer minutes js vuevue event countdownvue countdown examplecountdown timer inn vuecountdown vuevuejs countdown timer countdown in vue js npmcountdown timer vue js laravelvue timer componentvue js alert countdown timeracurate countdown timer vuevue js moment countdown timermaking a count down timer with vue bootstrapseconds countdown vuewatch time counter vuevue countdown secondsvue timersbuild a countdown timer in vue 3countdown with vue jsvue js input countdownvue countup timervue fancy countdownvue countdown clock npmtimer count down in vuejsvue js set timervue countdown timer npm start on clickvue js timer countdowncreate timer in vu jshow to set timer in vuevue countdownvue js count down timer