vuejs-tips / v-money

Tiny (<2k gzipped) input/directive mask for currency
https://vuejs-tips.github.io/v-money/
778 stars 255 forks source link

Initial value #35

Open leok85 opened 7 years ago

leok85 commented 7 years ago

If I start the component with an integer value, for example 50, it should interpret it as number 50.00, but with the mask the input number stays as 0.50

You can reproduce the problem by paste the number 50 https://vuejs-tips.github.io/v-money/

*sorry my english

renatosistemasvc commented 7 years ago

The problem happens when the data is of the type string. The library works correctly when the data is of type number.

It would be good to work in both situations.

bgoncal commented 6 years ago

Even if it's a number, didn't work for me @renatosistemasvc

eternalcode0 commented 6 years ago

Here's a reproduction https://stackblitz.com/edit/js-ueo8am?file=index.js

renatosistemasvc commented 6 years ago

I'm using the component:

<money v-model="price" v-bind="money"></money>

Instead of:

<input v-model.lazy="price" v-money="money" />

eternalcode0 commented 6 years ago

@renatosistemasvc So are the directive and and the component supposed to function differently? Either way, it seems the issue isn't with the component but rather with the directive.

renatosistemasvc commented 6 years ago

@eternalcode0 Yes! There is a bug in the directive. But if you use the direct component, the problem is solved. The component also uses the directive internally. But for some reason, using the component directly makes the problem go away.

I'm using it in my projects and it's working fine. I downloaded the src folder from this repository and adapted the library to work with null values and with vue element.

everything works fine!