Input field component to display currency value based on Vue.
Works with Vue 2.*
$ npm install vue-numeric --save<template> <vue-numeric currency="$" separator="," v-model="price"></vue-numeric> </template> <script> import VueNumeric from 'vue-numeric' export default { name: 'App', components: { VueNumeric }, data: () => ({ price: '' }), } </script> adding currency prefix to the input by using currency props.
<vue-numeric currency="$"></vue-numeric>Limit minimum and maximum input by using min, max props.
mindefault to0.min, maxacceptStringandNumber.
<vue-numeric min="2000" v-bind:max="10000"></vue-numeric>minusdefault tofalse.
<vue-numeric v-bind:minus="false"></vue-numeric>By default the decimal value is disabled, to use decimal value add precision props.
precisionacceptStringandNumbernumeric value.
<vue-numeric v-bind:precision="2"></vue-numeric>- Default thousand separator's symbol is
,. - Use
separatorprops to change separator's symbol. separatoronly accept either,or.value.- When using
.separator symbol, to input decimal value use,and vice versa.
<vue-numeric separator="."></vue-numeric><vue-numeric placeholder="only number allowed"></vue-numeric>| Props | Description | Required | Type | Default |
|---|---|---|---|---|
| currency | Currency prefix | false | String | - |
| max | Maximum value allowed | false | Number, String | - |
| min | Minimum value allowed | false | Number, String | 0 |
| minus | Enable/disable minus value | false | Boolean | false |
| placeholder | Input placeholder | false | String | - |
| precision | Number of decimals | false | Number, String | - |
| separator | Thousand separator type ( accept either . or , ) | false | String | , |
| read-only | Hide input field and show the value in text | false | Boolean | false |
| read-only-class | Class for read-only element | false | String | '' |
Vue-Numeric is open-sourced software licensed under the MIT license
