Posts

Showing posts with the label 7). Understanding Vue.js Lifecycle Hooks

7). Understanding Vue.js Lifecycle Hooks

Image
Each Vue instance goes through a series of initialization steps when it’s created It needs to set up data observation, compile the template, mount the instance to the DOM, and update the DOM when data changes. Along the way, it also runs functions called lifecycle hooks. 1). Creation Creation hooks are the very first hooks that run in your component. They allow you to perform actions before your component has even been added to the DOM.  2). beforeCreate The beforeCreatehook runs at the very initialization of your component. data has not been made reactive, and events have not been set up yet. <script>     export default {         beforeCreate() {             console.log('Nothing gets called before me!')         }     }  </script> 3). created You can access all data and events. 4). Mounting (DOM Inser...