vue understanding of the life cycle

  vue lifecycle hook: beforeCreate, created, beforeMount, mounted, beforeUpdate, update, beforeDestroy, destroyed, activated, deactivated, errorCaptured; in vue-v2.6 version, has added serverPrefetch hook;

  

  beforeCreate

    Within this hook function initializes inject, props, methods, data, computed, wacth, provied;

 

  created

    Within this hook function, will be hung in the example of execution vm. $ Mount (vm. $ Options.el)

    Because the data has been carried out within beforeCreate hook initialization, so we can operate some of the data in the instance data within the hook; for ajax request, usually due to a number of data sometimes manipulate the data in this hook, so personal a bit more, usually ajax request will be placed on the inside, in fact, created on or mounted for ajax not a big difference, because the time difference between the created and mounted in fact negligible, considering his teammates sometimes cause secondary rendering, in fact, is not necessary to consider, because the ajax request itself is asynchronous, generally depending on the particular need to consider where to put ajax, and react the same, mounted and componentDidMount edge dom examples here have hung in, we can deal with some of the dom

 

  activated

    This hook generally activated with the use of a keep-alive to perform cache component with keep-alive, access assembly when again directly in front of the hook skip function is no longer re-run, performed directly activated hook;

 

Guess you like

Origin www.cnblogs.com/mufc/p/11287202.html