What is the keep alive
Posted on Aug. 8, 2023, 7:44 p.m. by Bailey McNabb
Category:
The front end
Tag:
The front end
keep-alive
role
The redirect of the route will result in the destruction and reconstruction of the component, which will definitely cause the home page to reload. The keep-alive lease can cache the routing component. Keep-alive is a container in which components are not deleted but cached. When a route redirects, components are not deleted but left in memory.
grammar
keep-alive :include="[' component name 1', 'component name 2']
view-router /
/keep-alive
Copy the code
Application scenarios
When a component needs to be used frequently
summary
Keep-alive: This component is provided by VUE to cache components
Two additional lifecycle functions
After keep-alive, the component has two more lifecycle hook functions
activated () {}
deactivated () {}
Copy the code