Moment For Technology

What is the keep alive

Posted on Sept. 23, 2022, 3:37 p.m. by Bailey McNabb
Category: The front end Tag: The front end



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.


keep-alive :include="[' component name 1', 'component name 2']
	view-router /
Copy the code

Application scenarios

When a component needs to be used frequently


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

. To be added

About (Moment For Technology) is a global community with thousands techies from across the global hang out!Passionate technologists, be it gadget freaks, tech enthusiasts, coders, technopreneurs, or CIOs, you would find them all here.