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.
min
default to0
.min, max
acceptString
andNumber
.
<vue-numeric min="2000" v-bind:max="10000"></vue-numeric>
minus
default tofalse
.
<vue-numeric v-bind:minus="false"></vue-numeric>
By default the decimal value is disabled, to use decimal value add precision
props.
precision
acceptString
andNumber
numeric value.
<vue-numeric v-bind:precision="2"></vue-numeric>
- Default thousand separator's symbol is
,
. - Use
separator
props to change separator's symbol. separator
only 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 | , |
Vue-Numeric is open-sourced software licensed under the MIT license