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

161
Visualizações
get query value from url VueJs

I'm new vuejs learner and I want to get the query value from url to use it in the vue method as explained below.

This is the route:

{
    path: "/FetchData/:query?",
    name: "FetchData",
    component: FetchData,
}

And this is the link to redirect to the second page

   <router-link :to="{ path: '/FetchData', query: { query: country.countryName }}">

this is the api

 public IActionResult GetSubs(string query, int? subs)
    {
        return Ok(SubService.GetSubs(query, subsId));
    }

This is the vue method calling the api

getSubs() {
            axios.get("https://localhost:44391/api/Subs/GetSubs")
                .then(res => this.subs = res.data)
                .catch(err => console.log(err))
        }

And finally, this is the html to display data

 <div class="d-flex flex-row mb-3">
                        <div class="d-flex flex-column ml-2"><span>{{subs.subsId}}</span></div>
                    </div>
                    <h6 style="text-align:left">{{subs.label}}</h6>
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

if you're using vuejs 2 you can access query using: this.$route.query
but if you're using v3 it should be something like:

import { useRoute } from 'vue-router'
import { computed } from 'vue';

export default {
  setup() {
    const route = useRoute()

    return {
       query: computed( () => route.query )
    }
  }
}

then you can use this.query inside your method

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