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