v-money
v-money copied to clipboard
Value gets divided by 100 when it's an integer
See: https://jsfiddle.net/nj3cLoum/8/
Input should show 123 but shows 1,23
I found same problem. If the value is 123.50, it shows 12,35. If the precision is 3 to value 123.00, it shows 0,123. It's always ignoring the zero of right side.
No fixes yet?
Still have the bug
Any update
You can compute the value of the input. Imagine I have the value
received in props
or declared in data
:
computed: {
formattedAmount() {
return this.decimalFormat(this.value);
}
},
methods: {
decimalFormat(amount) {
return amount * (10 ** this.money.precision);
}
In the input, you can then just use :value="formattedAmount"
.
The method decimalFormat
will add zeros according to your precision. So you will always have the value that you intended.
You could even do this in same computed method:
computed: {
formattedAmount() {
return this.value * (10 ** this.money.precision);
}
},