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 :: how to disable onclick event in javascript 
Javascript :: get array index by key value js 
Javascript :: jquery find children not working 
Javascript :: how to send a message discord.js 
Javascript :: dynamic select option dropdown in jquery 
Javascript :: new line in react js 
Javascript :: replace text in string in javascript 
Javascript :: javascript string contains function 
Javascript :: how to get id of current element clicked 
Javascript :: discord.js v13 client 
Javascript :: prepend to array javascript 
Javascript :: javascript window size 
Javascript :: how to get seconds in timstamps js 
Javascript :: how to get last item in array javascript 
Javascript :: getelementsbyclassname remove class 
Javascript :: react toastify does not have design 
Javascript :: javascript change background color 
Javascript :: contains substring javascript 
Javascript :: how to add variables to an array 
Javascript :: nodejs file exists 
Javascript :: get offset from timezone javascript 
Javascript :: jshint esversion 6 
Javascript :: javascript get value 
Javascript :: javascript regex .test 
Javascript :: how to remove all child elements in javascript 
Javascript :: get element by click 
Javascript :: jquery check if exist 
Javascript :: How to get input file using js 
Javascript :: json api testing 
Javascript :: angular js parse json 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =