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

579
Vistas
Failed to resolve component <router-view> VueRouter

I have a project build with Vue.js 3.2.13 and Vue-Router 4.0.14. I think I do everything right but the browser raises an error "[Vue warn]: Failed to resolve component: router-view If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement. at "

My router.js file:

import { createRouter, createWebHistory } from "vue-router";

const routes = [
  {
    path: "/",
    name: "index",
    component: () => import("@/views/HomePage.vue"),
  },
  {
    path: "/signin",
    name: "signin",
    component: () => import("@/views/SignIn.vue"),
  },
  {
    path: "/signup",
    name: "signup",
    component: () => import("@/views/SignUp.vue"),
  },
];

const router = createRouter({
  history: createWebHistory(),
  routes,
});

export default router;

My main.js file;

import { createApp } from "vue";
import App from "./App.vue";


import { router } from "./router";


createApp(App).component("fa", FontAwesomeIcon).use(router).mount("#app");

Additionally App.vue:

<template>
  <div id="app">
    <HeaderNavbar />
    <router-view></router-view>
  </div>
</template>

When I run the project I get the warning on browser console:

[Vue warn]: Failed to resolve component: router-view
If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement. 
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The problem in your case is exporting router as default from router.js but importing it as named import in main.js.

Therefore, replacing

import { router } from "./router"; // ❌

with

import router from "./router"; // 👍

will make VueRouter work as expected. (I doubt routing currently works in your project. It shouldn't.)


Alternatively, adding a named export of router to router.js (and keeping the current import syntax in main.js) would also make the problem go away.
You can do that by adding export in front of const router = createRouter(/* etc... */, in that file. If you do this, export default router becomes obsolete (unused).

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