According to Vue.js documentation, the created
and mounted
events are described as follows:
created
The
created
event is called synchronously after the instance is created. By this point, the instance has completed setting up data observation, computed properties, methods, and watch/event callbacks. However, the mounting phase has not started yet, and the $el property will not be available.
mounted
The
mounted
event is triggered after the instance has been mounted, with el being replaced by vm.$el. When the root instance is mounted to an in-document element, vm.$el will also be in-document when mounted is called.This event is not invoked during server-side rendering.
While I grasp the concept in theory, I have 2 inquiries regarding practical application:
- Are there any scenarios where using
created
is preferable tomounted
? - In real-life coding situations, what are some practical uses of the
created
event?