Improve RouterView and KeepAlive features #2508
l246804
started this conversation in
Show and tell
Replies: 1 comment
-
Nice library! This is a "cool show and tell" so I will move it there. There are some open issues and RFCs about KeepAlive already that you might want to participate in |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
What problem is this solving
Enable precise control over cached component instances when combining
RouterView
withKeepAlive
.For instance, when the
route.path
is/user/:id
, distinct component instances can be mapped based on thefullPath
parameter.Proposed solution
By configuring RouterView props, the underlying component exposed via its default slot can be wrapped, allowing distinct component instances to be provided to KeepAlive for fine-grained control over route cache behavior.
Describe alternatives you've considered
I've implemented this feature by wrapping the
Component
from theRouterView
slot, and released it as a package named vue-router-better-view. The component accepts aresolveViewKey
prop to customize thename
of the wrapped component used byKeepAlive
. If not provided, it behaves identically to the originalRouterView
. Aside from a minor difference in template refs handling, the usage remains fully compatible. Would such a feature be considered for inclusion in the official Vue Router implementation?Beta Was this translation helpful? Give feedback.
All reactions