keep-alive, I want to dynamically determine whether a component is cached or not, because the way a component goes in is different, sometimes it needs caching and sometimes it doesn"t.
suppose there are three routes: a, B, and C.
requirements:
by default A
B jumps to A Magi An and does not refresh
C jumps to A Magi A Refresh
set the meta attribute in the A route:
{
path: "/",
name: "A",
component: A,
meta: {
keepAlive: true //
}
}
set beforeRouteLeave:
beforeRouteLeave (to, from, next) {
// meta
to.meta.keepAlive = true; // A
next();
}
set beforeRouteLeave:
beforeRouteLeave (to, from, next) {
// meta
to.meta.keepAlive = false; // A
next();
}
in this case, it will be fine after the first refresh from B to A.
how can I solve this problem when the value printed by my console.log (to.meta.keepAlive) is also true
? Wait online