I have an ionic-vue
app that uses vue-router
. When I navigate to a subroute, from the subroute changing to another tab, then go back to the tab which has the subroute still active and then pressing the back button causes my route to change to the other tab, but the animation still does go to the main tab of the sub route.
Let me clear this through an example:
My routes:
const routes = [
{
path: '/',
redirect: '/suite/ads'
},
{
path: '/suite/',
component: () => import('@/views/suite.vue'),
redirect: 'suite/ads',
children: [
/* DEFAULT */
{
path: '',
redirect: 'ads',
},
/* ALL ROUTES OF ADS */
{
path: 'ads',
component: () => import('@/views/ads/ads.vue'),
meta: {
routeName: 'ads'
}
},
{
path: 'ads/ad',
component: () => import('@/views/ads/ad.vue'),
meta: {
routeName: 'ads'
}
},
/* ALL ROUTES OF SHOP */
{
path: 'shop',
component: () => import('@/views/shop/shop.vue'),
meta: {
routeName: 'shop'
}
}
]
}
];
Let’s say I start at the /suite/ads
route. From there I navigate to /suite/ads/ad
(which also creates a back button in this route). From there I go to the route /suite/shop
(another tab!). From the /suite/shop
I go back to the /suite/ads
by pressing the ads tab. Doing this stil has the suite/ads/ad
route active (which I would expect). When I then press the back button, my route (in the URL) goes back to /suite/shop
but the view changes back to /suite/ads
.
My suite
component looks like this:
type or paste code here<template>
<ion-page>
<ion-tabs @ionTabsDidChange="changeCurrentRoute()">
<ion-tab-bar>
<ion-tab-button tab="ads" href="/suite/ads" selected>
<ion-icon :icon="activeRoute === 'ads' ? tv : tvOutline" />
<ion-label color="light">Advertenties</ion-label>
</ion-tab-button>
<ion-tab-button tab="shop" href="/suite/shop">
<ion-icon :icon="activeRoute === 'shop' ? bagHandle : bagHandleOutline" />
<ion-label color="light">Shop</ion-label>
</ion-tab-button>
</ion-tab-bar>
</ion-tabs>
</ion-page>
</template>
This seems like a bug? Or am I misunderstanding something here?