Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

262
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda