Lifecycle hooks
We have access to a variety of lifecycle hooks that fire at particular points during the creation of our Vue instance. These hooks range from prior to creation with beforeCreate
, to after the instance is mounted
, destroyed
, and many more in between.
As the following figure shows, the creation of a new Vue instance fires off functions at varying stages of the instance lifecycle.
We'll be looking at how we can activate these hooks within this section:
Vue.js instance lifecycle hooks
Taking advantage of the lifecycle hooks (https://vuejs.org/v2/guide/instance.html) can be done in a similar way to any other property on our Vue instance. Let's take a look at how we can interact with each one of the hooks, starting from the top; I'll be creating another project based on the standard webpack-simple
template:
// App.vue <template> </template> <script> export default { data () { return { msg: 'Welcome to Your Vue.js App' } }, beforeCreate() { console...