Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

330
Views
No puedo tener rutas de enrutador similares en Vue3

Estoy aprendiendo Vue3 y tratando de hacer algunas rutas, pero recibo un mensaje de error que no tiene sentido. Tal vez esté relacionado con algún tipo de "enrutamiento anidado", pero también traté de hacer "hijos" y no quería funcionar.

Esto funciona:

 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, }, ], });

Y esto no:

 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, }, ], });

Mensaje de error:

 4:29 error Unable to resolve path to module '../nonPrimaryADAccounts/CreateADAccount.vue' import/no-unresolved
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Si necesita una ruta anidada, el enfoque recomendado es usar una función para generar las rutas con el prefijo:

 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, }, ]), ]
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!