-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
What problem is this solving
Enable precise control over cached component instances when combining RouterView with KeepAlive.
For instance, when the route.path is /user/:id, distinct component instances can be mapped based on the fullPath 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 the RouterView slot, and released it as a package named vue-router-better-view. The component accepts a resolveViewKey prop to customize the name of the wrapped component used by KeepAlive. If not provided, it behaves identically to the original RouterView. 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?