Skip to content

Commit cb09779

Browse files
committed
fix number value
1 parent c318e01 commit cb09779

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,5 @@
2323
"vue.js"
2424
],
2525
"homepage": "https://github.com/kevinongko/vue-numeric#readme",
26-
"license": "MIT",
27-
"dependencies": {
28-
"lodash": "^4.17.4"
29-
}
26+
"license": "MIT"
3027
}

src/vue-numeric.vue

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
</template>
44

55
<script>
6-
import _ from 'lodash'
7-
86
export default {
97
108
name: 'vue-numeric',
@@ -45,11 +43,11 @@ export default {
4543
4644
computed: {
4745
defaultValue () {
48-
return _.toNumber(this.value)
46+
return this.formatToNumber(this.value)
4947
},
5048
5149
amountValue () {
52-
return _.toNumber(this.amount)
50+
return this.formatToNumber(this.amount)
5351
}
5452
},
5553
@@ -70,14 +68,18 @@ export default {
7068
return true
7169
},
7270
73-
format (value) {
71+
formatToNumber (value) {
72+
+value.replace(/[^0-9]+/g, '')
73+
},
74+
75+
formatToCurrency (value) {
7476
const numberWithSeparator = Number(value).toString().replace(/\B(?=(\d{3})+(?!\d))/g, this.separator)
7577
return this.currency + ' ' + numberWithSeparator
7678
},
7779
7880
updateValue (value) {
7981
if (this.checkMinValue(value) && this.checkMaxValue(value)) {
80-
this.amount = this.format(value)
82+
this.amount = this.formatToCurrency(value)
8183
this.$emit('input', value)
8284
}
8385
}

0 commit comments

Comments
 (0)