Can't get basic children route to work

Hi,

I am a complete beginner in Ionic

I’m watching the “Getting Started with Ionic Vue” video and I can’t reproduce the routing thing with a children (23:20 - 25:25).

here is my /router/index.ts:

import { createRouter, createWebHistory } from '@ionic/vue-router';
import { RouteRecordRaw } from 'vue-router';
import TabsPage from '../views/TabsPage.vue'


const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    redirect: '/tabs/dressings'
  },
  {
    path: '/tabs/',
    component: TabsPage,
    children: [
      {
        path: '',
        redirect: '/tabs/dressings'
      },
      {
        path: 'dressings',
        component: () => import('@/views/DressingPage.vue'),
        children:[
          {
            path: 'create',
            name: 'create',
            component: () => import('@/views/AddDressing.vue'),
          },

        ]
      },
      {
        path: 'tenues',
        component: () => import('@/views/TenuesPage.vue'),
      },
      {
        path: 'conseils',
        component: () => import('@/views/ConseilsPage.vue'),
      },
      {
        path: 'profil',
        component: () => import('@/views/ProfilPage.vue'),
      }
    ]
  }
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router

I can access to http://localhost:8100/tabs/dressings/ and http://localhost:8100/tabs/create but I can’t access to http://localhost:8100/tabs/dressings/create

What am I missing ?

Thanks for your help

1 Like

should be at the top level

const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    redirect: '/tabs/dressings'
  },
  {
    path: '/tabs/',
    component: TabsPage,
    children: [
      {
        path: '',
        redirect: '/tabs/dressings'
      },
      {
        path: 'dressings',
        component: () => import('@/views/DressingPage.vue')
      }
      {
        path: 'dressings/create',
        name: 'dressings-create',
        component: () => import('@/views/AddDressing.vue'),
      },
      {
        path: 'tenues',
        component: () => import('@/views/TenuesPage.vue'),
      },
      {
        path: 'conseils',
        component: () => import('@/views/ConseilsPage.vue'),
      },
      {
        path: 'profil',
        component: () => import('@/views/ProfilPage.vue'),
      }
    ]
  }
]
1 Like

Thanks for your answer, solved my problem ! :grin: