1
I have the following problem, I need to format an input value, directly when the user is filling the field (@keypress or @input).
When I use the method to format outside the input it works, but if I try to use it with the v-model I believe it conflicts the values.
What would be an alternative to this question?
That is the method:
formatPrice(value) {
let val = (value / 1).toFixed(2).replace(".", ",");
return val.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".");
}
That is the call:
{{ formatPrice(valorPrecoImovel) }}
<input class="ipt-precoimovel" type="text" v-model="valorPrecoImovel" v-on:keypress="isNumber($event); formatPrice;" id="precoImovel">
I can’t call the method inside the v-model, for example:
v-model="formatPrice(valorPrecoImovel)"
Do you want to format the value inside the input or just the one inside the template
{{ }}
?– Sergio
the value within the input
– haykou