forked from https://github.com/nosir/cleave.js
CleaveJS as a component of VueJS
git clone git@github.com:jrainlau/vue-cleave.git
cd vue-cleave && npm install
npm run dev
Find the main file in ./src/App.vue
and ./src/components/cleave.vue
.
<!-- App.vue -->
<template>
<Cleave :options='cleaveOptions' v-model='formatedValue'></Cleave>
</template>
<script>
import Cleave from './components/cleave.vue'
export default {
data() {
return {
formatedValue: '',
cleaveOptions: {
numeral: true,
numeralDecimalScale: 4
}
}
},
watch: {
'formatedValue': (val) => {
console.log(val)
}
},
components: {
Cleave
}
}
</script>
By using cleave.vue
as a component, there are three things for you to do:
- Import
cleave.vue
and set as a component of the parent. - Pass in the custom
cleaveOptions
prop. - Simply use
<Cleave></Cleave>
as a normal<input/>
field.
The options in vue-clive
is same to the the Doc below:
Vue-Cleave is licensed under the Apache License Version 2.0
-
Cleave.js is included under its Apache License Version 2.0
-
Google libphonenumber is included under its Apache License Version 2.0