Life-cycle hooks 31 / 42
Each component allows us to hook into its lifecycle. The most commonly used one is created
. You can use this to make ajax requests.
mounted
is called after the component "mounted" the DOM. At this point, DOM refs will be available.
Try adding the hook beforeDestroy
. This can be used to do any garbage collection (e.g. removing manual event listeners).
Note: There are a few more but less common hooks, you can check them out here if you are interested.