Vue: How to load a function upon page load?

Created on 22 Jun 2017  路  3Comments  路  Source: vuejs/vue

I'm a beginner VueJS programmer.
I only know how to trigger a function using @click method from VueJS. However , I want to know how to trigger function after the page loads, something like v-init from Angular.

Thanks!

Most helpful comment

If you are not asking for load of _window_ or DOMContentLoaded of _document_, you need to use vue's lifecycle hook.

In your case, mounted is what you want.

All 3 comments

If you are not asking for load of _window_ or DOMContentLoaded of _document_, you need to use vue's lifecycle hook.

In your case, mounted is what you want.

@jkzing Thank you for replying. I will check the method you've provided.

Hi, thanks for your interest but Github issues are for bug reports and feature requests only. You can ask questions on the forum, gitter or StackOverflow.

About your issue, what @jkzing said 馃槃

Was this page helpful?
0 / 5 - 0 ratings