Vue (2) - Life Cycle hook

 

 1 <div id="app">
 2     {{msg}}
 3 </div>
 4 <script type="text/javascript">
 5     var vm = new Vue({
 6         el        : '#app',
 7         data       : { msg : 'hi vue' },
 8         beforeCreate : function(){    console.log('beforeCreate');    },
 9         created      : function(){    console.log('created');         },
10         beforeMount  : function(){    console.log('beforeMount');     },
11         mounted      : function(){    console.log('mounted');         },
12         beforeUpdate : function(){    console.log('beforeUpdate');    },
13         updated      : function(){    console.log('updated');}        
 14      });
 15  </ Script > 
16  ! <- 
. 17      (. 1) beforeCreate
 18 is          after initialization instance, be called before the data observed (data observer) and event / watcher event configuration.
19      (2) the Created
 20          called immediately after an instance is created.
21          In this step, the following configuration examples have been completed: the observed data (data observer), the operational properties, and methods, watch / event event callbacks.
22          However, mount the stage has not yet begun, $ el property is not currently visible.
23      (3) beforeMount
 24-          before the start of the mount is called: the first related to the rendering function is invoked
 25      (4) Mounted
 26          . EL vm be replaced by the newly created $ el, hang in the success of
 27      (5) beforeUpdate
 28         Called when the data update
 29      (6) Updated
 30          components have been updated DOM, the component has been updated
 31      more life-cycle function details View API    
 32  ->

 

Guess you like

Origin www.cnblogs.com/abdusalam10/p/11902133.html