How does vue keetp-alive affect watch $route?

Caiji encountered a problem:
the router-view of app.vue is covered with a layer of keep-alive
when switching between secondary pages, you can enter and leave watch $route

however, if keepalive is removed, the watch is less than the entry and departure of $route, and neither the entry nor departure of the routing guards in the component can trigger

did I write bug, or will watch and guards be affected by keep alive?


this depends on where your watch is written.

if you are inside the page watch $route , then if there is no keepalive, there will be no watch, because the page has been destroyed after the route left. The purpose of keepalive is to keep the page even after the route leaves.

keepalive

Menu