Categories
Vue Answers

How to run code after a Vue component renders?

Spread the love

Sometimes, we want to run code after a Vue component renders.

In this article, we’ll look at how to run code after a Vue component renders.

How to run code after a Vue component renders?

To run code after a Vue component renders, we put the code in the updated hook.

For instance, we write

<script>
//...
export default {
  //...
  updated() {
    //...
  },
};
</script>

to add the update hook in our component so that the code inside is run after the component is rendered.

Conclusion

To run code after a Vue component renders, we put the code in the updated 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 *