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

269
Vistas
What is the best way to grab first URL segment from Vue.js hash mode?

I have this URL generated by my vue.js app

http://localhost:8080/#/url-groups

I need to access url-groups

I've tried

const firstSegment = new URL(window.location.href).pathname.split('/#/')

I kept getting '/'


I've also tried :

const firstSegment = new URL(window.location.href).pathname.split('#'); console.log(firstSegment);
VM21687:1 ['/']


const firstSegment = new URL(window.location.href).pathname.split('/#/'); console.log(firstSegment);
VM21719:1 ['/']


const firstSegment = new URL(window.location.href).pathname.split('/'); console.log(firstSegment);
VM21751:1 (2) ['', '']

Can someone pls correct me ?

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

0

Try out to get the hash segment then split using / as separator finally get the element of the splitted array :

const [,secondSegment] = new URL(window.location.href).hash.split('/')

or

const segment= new URL(window.location.href).hash.replace('#/','')
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