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 :: if not undefined javascript 
Javascript :: 150 pound in kg 
Javascript :: return elemnt from array 
Javascript :: jquery get value of input submit 
Javascript :: how to remove an object from jsonobject in java 
Javascript :: MongoNotConnectedError: Client must be connected before running operations 
Javascript :: react native button top right 
Javascript :: javascript reset form 
Javascript :: active nav links in next.js 
Javascript :: typeorm config 
Javascript :: how to print a line in javascript 
Javascript :: how to remove an element javascript html 
Javascript :: convert result of .innerHTML to number on javascript 
Javascript :: simple javascript code 
Javascript :: convert days into year month 
Javascript :: add onclick event jquery button 
Javascript :: programatic navigation vue router 
Javascript :: joi validation 
Javascript :: discord.js how to send a message to all guilds 
Javascript :: change source of image jquery 
Javascript :: ajax with progress bar 
Javascript :: javascript cehck if array is empty 
Javascript :: get random item from array javascript 
Javascript :: bootstrap 4 navbar-collapse not working angular 
Javascript :: preventdefault not working react 
Javascript :: stop interval js 
Javascript :: ajax syntax in javascript 
Javascript :: Creating a Node.js MySQL Database 
Javascript :: javascript round to 2 decimals 
Javascript :: javascript to remove few items from array 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =