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

435
Vistas
Get parameter from URL in Vue JS

I am working on SPA (Vue JS) and Laravel as API. I want when users will receive email to click on button that will sent them to specific route (already implemented).

So now i am struggling how to get the user id from the Vue JS part.

https://domain.test/admin/users/dashboard/user/65/show

65 from the URL is the user ID, so any idea how to extract that ID with java script from Vue JS?

I am not using vue router, this is Laravel route and Vue JS component is rendered from blade file.

I have implemented something like this bellow, but client refused...

https://domain.test/admin/users/dashboard/user/show?userId=65
about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

let id = window.location.href.split('/').slice(-2)[0]
about 4 years ago · Juan Pablo Isaza Denunciar

0

Since you're already rendering the page in a Blade file, you should already have access to the user ID server side.

In that case, simply add the variable server side. For example:

<a :href="'https://domain.test/admin/users/dashboard/user/' + {{ 
$user->id }} + '/show'">Go to Dashboard</a>
about 4 years ago · Juan Pablo Isaza Denunciar

0

To get parmeters from url you can use vue router for that like this:

const routes = [
    // dynamic segments start with a colon
    { path: '/users/:id', component: User },
  ]

const User = {
  template: '<div>User {{ $route.params.id }}</div>',
}

Here is the link for more examples and vue router documentation:

https://router.vuejs.org/guide/essentials/dynamic-matching.html

You can also get parameters with only vanilla JavaScripe like follow:

const queryString = window.location.search;
console.log(queryString);
// ?product=shirt&color=blue&newuser&size=m

//then you have to parse the url
const urlParams = new URLSearchParams(queryString);

const color = urlParams.get('color')
console.log(color);
// blue
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