I have a text input that allow user to type a number with maximum of 3 digits after decimal point:
<v-text-field type="text" :value="num" @change="changeNum($event)" />
<p>{{ num }}</p>
...
export default {
data: () => ({
num: 0
}),
methods: {
changeNum(e) {
let v = parseFloat(e);
if (!isNaN(v)) {
this.num = parseFloat(v.toFixed(3));
}
}
}
};
If I type '123.456'
, then num = 123.456
.
If I append text '789'
, then input will contain 123.456789
but num = 123.456
. So, user may think that the changes have been applied, but it is not...
How can I force the input to update, if changeNum
fails?