v-money Mask for Vue.js
Features
- Lightweight (<2KB gzipped)
- Dependency free
- Mobile support
- Component or Directive flavors
- Accept copy/paste
- Editable
For other types of mask, use vue-the-mask
Usage
A. Globally
// register directive v-money and component <money>Vue
https://jsfiddle.net/auom8st8/
B. Use as component: {{price}}
https://jsfiddle.net/nj3cLoum/2/
C. Use as directive:Must use vmodel.lazy
to bind works properly.
{{price}}
Properties
property | Required | Type | Default | Description |
---|---|---|---|---|
precision | true | Number | 2 | How many decimal places |
decimal | false | String | "." | Decimal separator |
thousands | false | String | "," | Thousands separator |
prefix | false | String | "" | Currency symbol followed by a Space, like "R$ " |
suffix | false | String | "" | Percentage for example: " %" |
masked | false | Boolean | false | If the component output should include the mask or not |
allowBlank | false | Boolean | false | If the field can start blank and be cleared out by user |