Basic routing using Quasar/Vue.js

15 Views Asked by At

It's my first Vue.js app and I have only limited knowledge of JavaScript. I started a new app using Quasar and I'm really struggling to make the basic routing work. This is the file it gave me, which works:

import { RouteRecordRaw } from 'vue-router';

const routes: RouteRecordRaw[] = [
  {
    path: '/',
    component: () => import('layouts/MainLayout.vue'),
    children: [
      {
        path: '',
        component: () => import('pages/Home.vue')
      }
    ]
  },

  // Always leave this as last one,
  // but you can also remove it
  {
    path: '/:catchAll(.*)*',
    component: () => import('pages/ErrorNotFound.vue'),
  }
]

export default routes;

Now I want to add more routes, I tried following the Quasar tutorial and added more routes:

import { RouteRecordRaw } from 'vue-router';

const routes: RouteRecordRaw[] = [
  {
    path: '/',
    component: () => import('layouts/MainLayout.vue'),
    children: [
      {
        path: '',
        component: () => import('pages/Home.vue')
      },
      {
        path: 'caisse/',
        children: [
          {
            path: '',
            component: () => import('pages/CaisseListe.vue')
          },
          {
            path: ':id',
            component: () => import('pages/CaisseDetail.vue')
          }
        ]
      }
    ]
  },

  // Always leave this as last one,
  // but you can also remove it
  {
    path: '/:catchAll(.*)*',
    component: () => import('pages/ErrorNotFound.vue'),
  },
];

export default routes;

But it doesn't work. 1. It's always the HomeView template that gets rendered, no matter what path I try to follow. 2. The ErrorNotFound is never displayed.

I got no errors in my console and I don't really know how to debug with that framework. If I replace Home.vue with one of the other views, the latter gets rendered correctly, so it's not a problem with the views or the layout.

0

There are 0 best solutions below