mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 03:00:58 +08:00
fix(vue): router guards are now fired correctly when written in a component (#23821)
resolves #23820
This commit is contained in:
@ -20,6 +20,14 @@ export const createViewStacks = (router: Router) => {
|
||||
const registerIonPage = (viewItem: ViewItem, ionPage: HTMLElement) => {
|
||||
viewItem.ionPageElement = ionPage;
|
||||
viewItem.ionRoute = true;
|
||||
|
||||
/**
|
||||
* This is needed otherwise Vue Router
|
||||
* will not consider this component mounted
|
||||
* and will not run route guards that
|
||||
* are written in the component.
|
||||
*/
|
||||
viewItem.matchedRoute.instances = { default: viewItem.vueComponentRef.value };
|
||||
}
|
||||
|
||||
const findViewItemByRouteInfo = (routeInfo: RouteInfo, outletId?: number, useDeprecatedRouteSetup: boolean = false) => {
|
||||
@ -202,6 +210,7 @@ export const createViewStacks = (router: Router) => {
|
||||
viewItem.mount = false;
|
||||
viewItem.ionPageElement = undefined;
|
||||
viewItem.ionRoute = false;
|
||||
viewItem.matchedRoute.instances = {};
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user