Vue JS call a function on load Example
In this post we will give you information about Vue JS call a function on load Example. Hear we will give you detail about Vue JS call a function on load ExampleAnd how to use it also give you demo for it if it is necessary.
If you want to call a function on page load in vue js then in this example i will show you how to trigger function on page load in vue js. we will run function on page load vue application.
we mostly require to call method on page load in our application. so you want to call function in vue.js app then you can do it using created option in vue js. So i will give full example so you can check it out.
Example:
<!DOCTYPE html>
<html>
<head>
<title>Vue JS call function on load Example - ItSolutionStuff.com</title>
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
</head>
<body>
<div id="app">
{{ message }}
</div>
<script type="text/javascript">
var app = new Vue({
el: '#app',
data: {
message: 'Hello Vue!'
},
methods:{
myFunctionOnLoad: function() {
console.log('call on load...');
}
},
created: function(){
this.myFunctionOnLoad()
}
})
</script>
</body>
</html>
I hope it can help you…
Hope this code and post will helped you for implement Vue JS call a function on load Example. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs