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

155
Vistas
Vue-router keeps appending # to existing routes. P.S this isn't the typical hash, history mode issue

Using Vue 3, i have my router file set up this way

import { createRouter, createWebHistory } from "vue-router";
import Home from "../views/Home.vue";


const routes = [
    {
        path: "/",
        name: "Home",
        component: Home,
    },
    {
        path: "/Portfolio",
        name: "Portfolio",
        component: () =>
            import(/*webpackChunkName: "DestinationDetails" */ "../views/Portfolio"),
    },
    {
        path: "/Services",
        name: "Services",
        component: () =>
            import(/*webpackChunkName: "DestinationDetails" */ "../views/Services"),
    },

    {
        path: "/details/:id",
        name: "PortfolioDetails",
        component: () =>
            import(
                /*webpackChunkName: "DestinationDetails" */ "../views/PortfolioDetails"
            ),
    },
    {
        path: "/:pathMatch(.*)*",
        redirect: "/Home",
    },
];

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

export default router;

I am also running a v-for loop to get paths from an API "https://api.fake.rest/ca2a6662-22d0-4010-ba08-0440ffe813ab/menu". 3 of the 5 url paths have a value of "#". the remaining two have normal paths.

<div
                    v-for="(men, index) in webMenu.menu_items"
                    :key="index"  class=" mt-32"
                >
                    <!-- <SidebarLink class="w-full" :to="{path:men.url}" icon="fas fa-home">{{
                        men.name
                    }}</SidebarLink> -->

                    <router-link class="w-full" :to="men.url"> {{men.name}} </router-link>
                </div>

                <p class="font-bold">{{webMenu.menu_text}}</p>
            </div>

Problem is now when the webpage loads initially, it works fine but after clicking on the portfolio or services link, the paths to the others are changed.

e.g if i was on the portfolio page and tried switching back to the home page, it would change the route path to "portfolio#" and refuse to switch pages.

Can anyone help explain why this is and a possible way to resolve it?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

I was also facing the similar issue.

For me the problem was that I was redirecting to a new page using router.push() when clicking on a div.

And I was using @click.stop = "myFunction" . This was adding a # in the URL and not redirecting the user.

I tried different variations of this as well. I tried to use the event object also like event.stopPropagation() . With this I also got the same result.

When I used @click.prevent , everything worked as expected.

P.S:

You can also use the catch block to trace the error.

 this.$router..push({ name: "PAthName", params: { id }, query: { id } }) .catch(e => { console.log("Errors", e); });
about 4 years ago · Juan Pablo Isaza Denunciar

0

Should have updated this earlier.

The fix was relatively simple, all i did was change the binding from

<router-link class="w-full" :to="men.url"> {{men.name}} </router-link>

to

<router-link class="w-full" :to="`/${men.url}`"> {{men.name}} </router-link>

and voila!

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