Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

vue js countdown timer

<template>
   {{ countDown }}
</template>

<script>
    export default {
        data() {
            return {
                countDown : 10
            }
        },
        method: {
            countDownTimer() {
                if(this.countDown > 0) {
                    setTimeout(() => {
                        this.countDown -= 1
                        this.countDownTimer()
                    }, 1000)
                }
            }
        }
        created: {
           this.countDownTimer()
        }
    }
</script>
Comment

countdown using vue

<template>
    {{ timerCount }}
</template>

<script>

    export default {

        data() {
            return {
                timerCount: 30
            }
        },

        watch: {

            timerCount: {
                handler(value) {

                    if (value > 0) {
                        setTimeout(() => {
                            this.timerCount--;
                        }, 1000);
                    }

                },
                immediate: true // This ensures the watcher is triggered upon creation
            }

        }
    }

</script>
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript find matching elements in two arrays 
Javascript :: learn mongodb 
Javascript :: mongoose count 
Javascript :: remove the first item from an array 
Javascript :: run jest test for a single file 
Javascript :: node.js check if a remote URL exists 
Javascript :: angular build deploy url 
Javascript :: @click vue target 
Javascript :: SyntaxError: await is only valid in async function 
Javascript :: appendchild javascript 
Javascript :: select parent of elemt 
Javascript :: cache request in vue 
Javascript :: java script zip function 
Javascript :: nextjs react native web typescript 
Javascript :: how to insert with variables from js to mysql 
Javascript :: pop up notification using jquery 
Javascript :: DC League of Super-Pets 
Javascript :: javascript check if in array 
Javascript :: javascript add element to serialized form array 
Javascript :: get the length of an object vuejs 
Javascript :: mongoose search 
Javascript :: javascript array.isarray 
Javascript :: angular tab change smooth transition 
Javascript :: add countdown timer to javascript quiz 
Javascript :: javascript variable in html string 
Javascript :: pass param to url retrofit 
Javascript :: upgrade or update nodejs 
Javascript :: how to import modules js 
Javascript :: make an arry from a string 
Javascript :: javascript location.href 
ADD CONTENT
Topic
Content
Source link
Name
4+4 =