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

235
Visualizações
how to make blur not replacing value on event with it previous value

I have two inputs that use the same function to set a new value like this

<b-input
    v-model="ownerProps.approver2ExtraCost"
    @blur="onClick($event)"
    class="inputBuefy"
  ></b-input>
</div>
<b-input
    class="inputBuefy"
    @blur="onClick($event)"
    v-model="ownerProps.approver3ExtraCost"
  ></b-input>
</div>

they have different v-models but I'm using the same function to change their values on my methods property.

onClick(e) {
  console.log(e.target.value);
  e.target.value = "dfg";
}

The thing is, when I change one of the following inputs it gets the previously value that I typed. for example:

if typed 'ABC' in the first input

replaces it with 'dfg'

But when I go to the next input, and I type something like 'HIJ'

the first input get its previous value = 'ABC'

But it should have remained with 'dfg'

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Your problem is that you are setting the value of the element and not changing the value of the bounded variable which you should do.
so when vue "refreshes" it updates the input

do this instead

<b-input
    v-model="ownerProps.approver2ExtraCost"
    @blur="onClick(2)"
    class="inputBuefy"
  ></b-input>
</div>
<b-input
    class="inputBuefy"
    @blur="onClick(3)"
    v-model="ownerProps.approver3ExtraCost"
  ></b-input>
</div>

and change your function to

onClick(id) {
  if (id === 2) ownerProps.approver2ExtraCost = "dfg";
  if (id === 3) ownerProps.approver3ExtraCost = "dfg";
}

you should ideally have those elements in a array instead and send the index of what you want to change

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