mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-16 10:01:59 +08:00
fix(vue): canGoBack now returns correct result with initial load redirect (#22071)
This commit is contained in:
@ -31,15 +31,6 @@ export const createIonRouter = (opts: IonicVueRouterOptions, router: Router) =>
|
||||
// TODO types
|
||||
let historyChangeListeners: any[] = [];
|
||||
|
||||
const currentRoute = router.currentRoute.value;
|
||||
currentRouteInfo = {
|
||||
id: generateId('routeInfo'),
|
||||
pathname: currentRoute.path,
|
||||
search: currentRoute.fullPath.split('?')[1] || '',
|
||||
params: currentRoute.params
|
||||
}
|
||||
locationHistory.add(currentRouteInfo)
|
||||
|
||||
if (typeof (document as any) !== 'undefined') {
|
||||
document.addEventListener('ionBackButton', (ev: Event) => {
|
||||
(ev as any).detail.register(0, (processNextHandler: () => void) => {
|
||||
@ -105,6 +96,13 @@ export const createIonRouter = (opts: IonicVueRouterOptions, router: Router) =>
|
||||
leavingLocationInfo = locationHistory.current();
|
||||
}
|
||||
|
||||
if (!leavingLocationInfo) {
|
||||
leavingLocationInfo = {
|
||||
pathname: '',
|
||||
search: ''
|
||||
}
|
||||
}
|
||||
|
||||
const leavingUrl = leavingLocationInfo.pathname + leavingLocationInfo.search;
|
||||
if (leavingUrl !== location.fullPath) {
|
||||
if (!incomingRouteParams) {
|
||||
|
Reference in New Issue
Block a user