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