diff --git a/packages/vue-router/src/viewStacks.ts b/packages/vue-router/src/viewStacks.ts index 3b89113725..15a4885704 100644 --- a/packages/vue-router/src/viewStacks.ts +++ b/packages/vue-router/src/viewStacks.ts @@ -23,31 +23,7 @@ export const createViewStacks = (router: Router) => { } const findViewItemByRouteInfo = (routeInfo: RouteInfo, outletId?: number) => { - let viewItem = findViewItemByPath(routeInfo.pathname, outletId, false); - - /** - * Given a route such as /path/:id, - * going from /page/1 to /home - * to /page/2 will cause the same - * view item from /page/1 to match - * for /page/2 so we need to make - * sure any params get updated. - * Not normally an issue for accessing - * the params via useRouter from vue-router, - * but when passing params as props not doing - * this would cause the old props to show up. - */ - if (viewItem && viewItem.params !== routeInfo.params) { - /** - * Clear the props function result - * as the value may have changed due - * to different props. - */ - delete viewItem.vueComponentData.propsFunctionResult; - viewItem.params = routeInfo.params; - } - - return viewItem; + return findViewItemByPath(routeInfo.pathname, outletId, false); } const findLeavingViewItemByRouteInfo = (routeInfo: RouteInfo, outletId?: number, mustBeIonRoute: boolean = true) => { @@ -81,6 +57,20 @@ export const createViewStacks = (router: Router) => { const findMatchedRoute = resolvedPath.matched.find((matchedRoute: RouteLocationMatched) => matchedRoute === viewItem.matchedRoute); if (findMatchedRoute) { + + /** + * /page/1 and /page/2 should not match + * to the same view item otherwise there will + * be not page transition and we will need to + * explicitly clear out parameters from page 1 + * so the page 2 params are properly passed + * to the developer's app. + */ + const hasParameter = findMatchedRoute.path.includes(':'); + if (hasParameter && path !== viewItem.pathname) { + return false; + } + return viewItem; } diff --git a/packages/vue/test-app/src/router/index.ts b/packages/vue/test-app/src/router/index.ts index f3701f2179..ae08e71890 100644 --- a/packages/vue/test-app/src/router/index.ts +++ b/packages/vue/test-app/src/router/index.ts @@ -90,12 +90,9 @@ const routes: Array = [ component: () => import('@/views/Tab1.vue'), }, { - path: 'tab1/child-one', - component: () => import('@/views/Tab1ChildOne.vue') - }, - { - path: 'tab1/child-two', - component: () => import('@/views/Tab1ChildTwo.vue') + path: 'tab1/:id', + component: () => import('@/views/Tab1Parameter.vue'), + props: true }, { path: 'tab2', diff --git a/packages/vue/test-app/src/views/RoutingParameter.vue b/packages/vue/test-app/src/views/RoutingParameter.vue index ffeac7f0f0..36c74e2fcc 100644 --- a/packages/vue/test-app/src/views/RoutingParameter.vue +++ b/packages/vue/test-app/src/views/RoutingParameter.vue @@ -1,5 +1,5 @@