Categories
Vue Answers

How to trigger event after component has been rendered in Vue.js?

Spread the love

Sometimes, we want to trigger event after component has been rendered in Vue.js.

In this article, we’ll look at how to trigger event after component has been rendered in Vue.js.

How to trigger event after component has been rendered in Vue.js?

To trigger event after component has been rendered in Vue.js, we can call this.$emit in the mounted hook.

For instance, we write

<script>
export default {
  //...
  mounted() {
    this.$emit("loaded");
  },
  //...
};
</script>

to emit the loaded event in the mounted hook with this.$emit.

Conclusion

To trigger event after component has been rendered in Vue.js, we can call this.$emit in the mounted hook.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *