Vue.js setTimeOut


Vue.js setTimeOut– We can use native setTimeOut in Vue.JS. Here in this tutorial, we are going to explain how to use setTimeOut function Vue.JS.


How to Use setTimeOut in Vue.JS Example

You can use setTimout function vue.js simply as below-

Example:

<!DOCTYPE html>
<html>
<head>
 <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.13/vue.js"></script>
</head>
<body>
<div id="app">
	 {{message}}
</div>
<script>
 new Vue({
  el: '#app',
  data: {
    message:"Hello World!"
  },
  methods:{
    testFunction: function () {
      var v = this;
      setTimeout(function () {
        v.message = "Hi Vue!";
    }, 3000);
   }
	},
 mounted () {
  this.testFunction()
}
 });
	
</script>        
</body>
</html>

Try it »

In the above example we have created function testFunction and called setTimeOut function on mount state. Run the above example and wait for 3 seconds to see the output of timeOutFunction.

Output of above example-

Vue.js setTimeOut function example

Advertisements

Add Comment

📖 Read More