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

235
Vistas
Vue.js - Define path of vue route based on URL query params

Let's assume I have this URL http://localhost:8080/public/form?code=fhuZ15aHy

I have defined a route in my route.js file like this

{ 
  path: '/public/form?code=:code',
  name: 'survey',
  component: () => import('./views/form')
}

which is supposed to reuse the same component based on the code query parameter coming from URL.

In my form.vue component I have defined a prop like this:

props: {
   code: {
       type: String,
       required: true
   }
}

But this is not working, in the sense that I am not redirected to any page.

I think I'm doing wrong with how I defined the path of the route. How can I achieve this?

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

0

Do not define the query within the path

You should write like this:

{ 
  path: '/public/form',
  name: 'survey',
  component: () => import('./views/form')
}
router.push({ path: '/public/form', query: { code } })

And within the component you can access the query like this

const {code} = this.$route.query
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