Vue call function on load functional component: Vue.js provides a convenient method to call a function when the page is loaded When using Vue.js, it is possible to call a function on page load by including the function within the `mounted` lifecycle hook for your vue instance. The mounted function is used to call a function when the page is initially loaded. When the page or browser loads, all of the functions on the mounted component are called. In this tutorial, we will learn how to call a function when a web page or browser is loaded with the help of Vue.js.
How to call a vue.js function/method on page load?
In order to call a Vue.js function or method on page load, you can use the mounted() method in Vue. A mounted component is a function that is used when a page or application first loads. This component is a function that runs automatically when the page is loaded, and it can be used to call any other function at that time.
Vue Js run function on page load
<script type="module">
import { createApp } from "vue";
createApp({
data() { return {} },
mounted() {
this.demo()
},
methods: {
demo() { alert('fontawesomeicons') }
}
}).mount("#app");
</script>