vue his son's life cycle hook function components and buffer components which function can be used

Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/qq_34664239/article/details/90287056

Recently do vue of caching, routing is more complex, recognizing several new hook function, in this case record

Lifecycle Functions
  • beforeCreate
  • created
  • beforeMount
  • mounted
  • beforeUpdate
  • updated
  • beforeRouteEnter
  • beforeRouteLeave
  • activated
  • deactivated
  • beforeDestroy
  • destroyed
First, the relationship between the components function
In assembly 1. keep-alive
  • There caching, the component rendering finished once and only perform deactivated,dedeactivatedtwo functions
  • When there is a cache, also performs two functions beforeRouterEnter and beforeRouterLeave
2. Brothers components
  • When the route change occurs, a component before performing beforeDestroythe time, a location has changed window.location.href component
3. Sons components
  • When the route changes, the normal component will trigger route和destroyhook
  • Subassemblies no beforeRouteEnter, beforeRouteLeave
  • Sub-components, the parent does not cache when the routing changes by beforeDestroy,destroyedmonitoring
  • Sub-components, the parent has the cache when the routing changes by activated,deactivatedmonitoring
Second, the child and parent route cache routing problem

1. Parent added routing cache, cache sub-route did not increase, the sub-assembly is not cached route
2. route did not increase the parent cache, cache sub-route add, when the parent route change, the route sub-cache miss, the parent routing unchanged, sub-route cache entry into force

Detailed: https://blog.csdn.net/qq_34664239/article/details/89499120

Guess you like

Origin blog.csdn.net/qq_34664239/article/details/90287056