Hello. I am experiencing some weird behavior when trying to create a route with an optional parameter.
Here is the router code:
import { createRouter, createWebHistory } from '@ionic/vue-router';
import TabsPage from '../views/TabsPage.vue'
import Results from '@/views/tabs/Results.vue'
const routes = [
{
path: '/',
redirect: '/tabs/home'
},
{
path: '/tabs/',
component: TabsPage,
children: [
{
path: '',
redirect: '/tabs/home'
},
{ // This causes the problem
path: 'results/:id?',
component: Results,
},
{
path: 'home',
component: () => import('@/views/tabs/Home.vue')
},
{
path: 'tab3',
component: () => import('@/views/Tab3Page.vue')
}
]
}
]
const router = createRouter({
history: createWebHistory(process.env.BASE_URL),
routes
})
export default router
The tabs are defined like this:
<ion-tab-button tab="home" href="/tabs/home">
And the child route is called like that:
<ion-item button :router-link="'/tabs/results/'+result.id">
This behavior begins only after going to the child route “/tabs/results/:id”
Let me know if the problem doesn’t become clear from the video. The app hangs when switching between tabs, sometimes the tab buttons lead to an incorrect route. Seems like the whole webview is refreshed sometimes. There also seems to be an animation bug (kind of like it’s triggered twice). This strange behavior is more obvious on android than in the browser.
Am I doing something wrong is it a bug? Thanks in advance!