Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

223
Vistas
I cannot have similar router paths in Vue3

I'm just learning Vue3 and trying to do some routing, but I'm getting an error message that makes no sense. Maybe it's related to some kind of nested routing, but I also tried to do children and it didn't want to work.

This works:

import { createRouter, createWebHistory } from 'vue-router';
import HomePage from '../home/HomePage.vue';
import FetchAccount from '../nonPrimaryADAccounts/FetchAccount.vue';
import CreateADAccount from '../nonPrimaryADAccounts/CreateADAccount.vue';

export default createRouter({
  history: createWebHistory(),
  routes: [
    {
      path: '/',
      name: 'Home',
      component: HomePage,
    },
    {
      path: '/FetchAccount',
      name: 'FetchAccount',
      component: FetchAccount,
    },
    {
      path: '/CreateADAccount',
      name: 'CreateADAccount',
      component: CreateADAccount,
    },
  ],
});

And this does not:

import { createRouter, createWebHistory } from 'vue-router';
import HomePage from '../home/HomePage.vue';
import FetchAccount from '../nonPrimaryADAccounts/FetchAccount.vue';
import CreateADAccount from '../nonPrimaryADAccounts/CreateADAccount.vue';

export default createRouter({
  history: createWebHistory(),
  routes: [
    {
      path: '/',
      name: 'Home',
      component: HomePage,
    },
    {
      path: '/NonPrimaryADAccount/FetchAccount',
      name: 'FetchAccount',
      component: FetchAccount,
    },
    {
      path: '/NonPrimaryADAccount/CreateADAccount',
      name: 'CreateADAccount',
      component: CreateADAccount,
    },
  ],
});

Error message:

4:29  error  Unable to resolve path to module '../nonPrimaryADAccounts/CreateADAccount.vue'  import/no-unresolved
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If you need nested path the recommended approach is to use a function to generate the routes with the prefix:

const withPrefix = (prefix, routes) => 
    routes.map( (route) => {
        route.path = prefix + route.path;
        return route;
    });

export default createRouter({
  history: createWebHistory(),
  routes: [
    {
      path: '/',
      name: 'Home',
      component: HomePage,
    },
    ...withPrefix('/NonPrimaryADAccount',[
        { 
          path: '/FetchData',
          name: 'FetchData',
          component: FetchData,
        },
        { 
          path: '/CreateADAccount',
          name: 'CreateADAccount',
          component: CreateADAccount,
        },
    ]),
]
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda