ItSolutionStuff.com

Vue JS Call a Function On Load Example

By Hardik Savani • July 5, 2023
Vue.JS

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...

Tags: Vue.JS
Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

Vue JS Get Selected Option Text Example

Read Now →

How to Get Data Attribute Value in Vue JS?

Read Now →

Vue JS Get Array Length or Object Length Example

Read Now →

Vue JS Ajax Form Submit Example Code

Read Now →

How to Get Current Date and Time in Vue JS?

Read Now →

How to use datepicker in vuejs?

Read Now →

Vue JS MultiSelect Dropdown Example

Read Now →

How to Change Date Format using Moment in Vue JS?

Read Now →

How to Replace String in Vue JS?

Read Now →

How to Open a Link in a New Tab in Vue JS?

Read Now →

How to Use setTimeout Function in Vue JS?

Read Now →

How to Check Object or Array Empty or Not in Vue JS?

Read Now →

How to Get Element by ID in Vue JS?

Read Now →

Vue JS Scroll to Element in Div using Vue-scrollto Example

Read Now →