[Vuejs]-Why Vue doesn't show data from my WebApi with axios and params?

0👍

It seems kind of strange. I conclude you reading it properly on server-side. So I bet your server only wants Number(7) not String(7). You should change basic stance of busqueda to null. Then add .number modifier to v-model. Like that:

<input type="text" class="form-control" v-model.number="busqueda" placeholder="Buscar usuario" />

How to prevent load the page everytime you push button?
Add .prevent modifier.
Change:

<button type="submit" class="btn btn-default" v-on:click="buscarUsuario">Buscar</button>

To:

<button type="submit" class="btn btn-default" v-on:click.prevent="buscarUsuario">Buscar</button>

Also I recomend use @ as shortcut for v-on:(in this example you could have use @click.prevent).

If it still refreshes. Add @submit.prevent=”functionName” to form…

0👍

Use id without quote and click.prevent to prevent submit.

params: {
  id: 7
}
<button type="submit" class="btn btn-default" v-on:click.prevent="buscarUsuario">Buscar</button>

also you can use button type=”buttton”

<button type="button" class="btn btn-default" v-on:click="buscarUsuario">Buscar</button>

Leave a comment