You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Enhances the [RouterView & KeepAlive](https://router.vuejs.org/guide/advanced/router-view-slot.html#KeepAlive-Transition) functionality of [Vue Router](https://router.vuejs.org/).
3
+
An extension for [Vue Router](https://router.vuejs.org/)'s [RouterView](https://router.vuejs.org/guide/advanced/router-view-slot.html#RouterView-slot) with enhanced features.
-[x] Enhanced [RouterView & KeepAlive](https://router.vuejs.org/guide/advanced/router-view-slot.html#KeepAlive-Transition) functionality with support for dynamic parameter route caching
8
+
-[x] Precise rendering (ignore parent routes with components) for intuitive nested route handling
The current [RouterView](file:///home/leihaohao/workspaces/own/vue-router-better-view/node_modules/.pnpm/[email protected][email protected][email protected]_/node_modules/vue-router/dist/vue-router.d.ts#L1603-L1613) component in Vue Router has the following limitations when used with the [KeepAlive](https://cn.vuejs.org/api/built-in-components.html#keepalive) component:
16
+
Current issues with Vue Router:
17
+
18
+
### 1. **Dynamic Route Caching Problems**
19
+
20
+
-**Issue 1**: When using `KeepAlive`, cannot precisely control component instance caching for dynamic routes (e.g., `/user/:id`)
21
+
-**Issue 2**: Route component `name` must match route configuration's `name` attribute for proper caching
12
22
13
-
1. Unable to cache different parameters of the same component instance based on [dynamic route matching](https://router.vuejs.org/guide/essentials/dynamic-matching.html).
14
-
2. Route components must have distinct [name](file:///home/leihaohao/workspaces/own/vue-router-better-view/node_modules/.pnpm/[email protected][email protected][email protected]_/node_modules/vue-router/dist/vue-router.d.ts#L244-L244) attributes; otherwise, components with the same name will cause caching issues.
23
+
### 2. **Nested Route Rendering Issues**
15
24
16
-
This plugin provides a simple and efficient solution to the above problems.
25
+
-**Issue 1**: Official nested routes require either nested `RouterView` or flat route registration, leading to:
26
+
-**Nested RouterView approach**: Redundant rendering logic in sub-pages
27
+
-**Flat registration**: Loses `route.matched` convenience and feels unintuitive
28
+
29
+
This plugin solves these issues through the `BetterRouterView` component with a more efficient solution.
0 commit comments