v-money icon indicating copy to clipboard operation
v-money copied to clipboard

Value gets divided by 100 when it's an integer

Open xps opened this issue 7 years ago • 5 comments

See: https://jsfiddle.net/nj3cLoum/8/

Input should show 123 but shows 1,23

xps avatar Aug 11 '17 14:08 xps

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.

wagnereliakim avatar Oct 11 '17 02:10 wagnereliakim

No fixes yet?

phiter avatar Jan 03 '18 12:01 phiter

Still have the bug

bgoncal avatar Mar 24 '18 01:03 bgoncal

Any update

npulukuri avatar Sep 24 '18 17:09 npulukuri

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);
  }
},

SrAxi avatar Oct 15 '18 07:10 SrAxi