Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

261
Views
¿Cuál es la mejor manera de obtener el primer segmento de URL del modo hash de Vue.js?

Tengo esta URL generada por mi aplicación vue.js

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

Necesito acceder a url-groups

He intentado

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

Seguí recibiendo '/'


También he intentado:

 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) ['', '']

¿Puede alguien por favor corregirme?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Intente obtener el segmento hash y luego divídalo usando / como separador y finalmente obtenga el elemento de la matriz dividida:

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

o

 const segment= new URL(window.location.href).hash.replace('#/','')
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!