uu
This commit is contained in:
parent
0132881ab9
commit
f20d60f69f
@ -125,13 +125,21 @@
|
|||||||
},
|
},
|
||||||
formatter(val) {
|
formatter(val) {
|
||||||
let newVal = val
|
let newVal = val
|
||||||
if(this._digit) {
|
if((this.type == 'number' || this._digit || this._maxNum) && (typeof val == 'string' && val)) {
|
||||||
let reg = new RegExp(`^\\d*(\\.?\\d{0,${this._digit}})`, 'g')
|
newVal = Number(val) // 需要格式化输入框的格式
|
||||||
newVal = val.match(reg)[0]
|
// 判断是否输入了数字
|
||||||
}
|
if(!isNaN(newVal)) {
|
||||||
if(typeof this._maxNum != 'undefined') {
|
if(this._digit) {
|
||||||
if(val > this._maxNum) {
|
let reg = new RegExp(`^\\d*(\\.?\\d{0,${this._digit}})`, 'g')
|
||||||
newVal = this._maxNum
|
newVal = val.match(reg)[0]
|
||||||
|
}
|
||||||
|
if(typeof this._maxNum != 'undefined') {
|
||||||
|
if(newVal > Number(this._maxNum)) {
|
||||||
|
newVal = this._maxNum
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
newVal = ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return newVal
|
return newVal
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user