File tree Expand file tree Collapse file tree 2 files changed +9
-10
lines changed Expand file tree Collapse file tree 2 files changed +9
-10
lines changed Original file line number Diff line number Diff line change 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}
Original file line number Diff line number Diff line change 33</template >
44
55<script >
6- import _ from ' lodash'
7-
86export 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 }
You can’t perform that action at this time.
0 commit comments