Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

There are different ways to invoke a function after the page has finished loading in Vue.js:

  1. Using the mounted lifecycle hook: This hook is called after the component has been mounted to the DOM. You can define the function inside the mounted hook like this:
mounted() {
  // invoke your function here
}
  1. Using the created lifecycle hook: This hook is called before the component is mounted to the DOM, but after the component has been initialized. You can define the function inside the created hook like this:
created() {
  // invoke your function here
}
  1. Using v-once directive: You can use the v-once directive to render an element only once and then prevent it from re-rendering. You can add the function call to this element like this:
<div v-once>
  <!-- your HTML code here -->
  {{ yourFunction() }}
</div>

You can choose the method which suits your requirement the most.