I have a problem with navigation in the Ionic Vue app: navigation back does not work from subpages in the tabs-layout application. The app itself is very simple, it consists of 3 tabs pages, and 4 subpages. Schematically, it looks like this:
- Page 1
- Subpage 1.1
- Subpage 1.2
- Page 2
- Subpage 2.1
- Subpage 2.2
- Page 3
I created a basic app using ionic create
and extended routes and pages.
Routes file:
const routes: Array<RouteRecordRaw> = [
{
path: "/",
redirect: "/tabs/tab1",
},
{
path: "/tabs/",
component: TabsPage,
children: [
{
path: "",
redirect: "/tabs/tab1",
},
{
path: "tab1",
component: () => import("@/views/Tab1Page.vue"),
},
{
path: "tab1/subpage1",
component: () => import("@/views/Tab1Subpage1.vue"),
},
{
path: "tab1/subpage2",
component: () => import("@/views/Tab1Subpage2.vue"),
},
{
path: "tab2",
component: () => import("@/views/Tab2Page.vue"),
},
{
path: "tab2/subpage1",
component: () => import("@/views/Tab2Subpage1.vue"),
},
{
path: "tab2/subpage2",
component: () => import("@/views/Tab2Subpage2.vue"),
},
{
path: "tab3",
component: () => import("@/views/Tab3Page.vue"),
},
],
},
];
Page1 and Page2 source code (they are the same except of labels):
<template>
<ion-page>
<ion-header>
<ion-toolbar>
<ion-title>Tab 1</ion-title>
</ion-toolbar>
</ion-header>
<ion-content :fullscreen="true">
<ion-header collapse="condense">
<ion-toolbar>
<ion-title size="large">Tab 1</ion-title>
</ion-toolbar>
</ion-header>
<ion-button router-link="tab1/subpage1">Subpage 1</ion-button>
<ion-button router-link="tab1/subpage2">Subpage 2</ion-button>
</ion-content>
</ion-page>
</template>
<script setup lang="ts">
import {
IonPage,
IonHeader,
IonToolbar,
IonTitle,
IonContent,
IonButton,
} from "@ionic/vue";
</script>
Subpages look like this:
<template>
<ion-page>
<ion-header>
<ion-toolbar>
<ion-buttons slot="start">
<ion-back-button></ion-back-button>
</ion-buttons>
<ion-title>Tab 1 Pag 1</ion-title>
</ion-toolbar>
</ion-header>
<ion-content :fullscreen="true"> Tab 1 Pag 1 </ion-content>
</ion-page>
</template>
<script setup lang="ts">
import {
IonPage,
IonContent,
IonHeader,
IonToolbar,
IonTitle,
IonButtons,
IonBackButton,
} from "@ionic/vue";
</script>
I created a record of the issue, you can see it here: Ionic App - YouTube
How can I fix it? Thank you for any advice!