Skip to content

Commit

Permalink
bugfix(input): 修复数字输入框在空值的时候点击上下按键不显示最大/小值的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
zc422 committed Jul 15, 2024
1 parent 8517024 commit 1fd9c7b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/components/input/input.vue
Original file line number Diff line number Diff line change
Expand Up @@ -594,15 +594,15 @@ export default {
}
},
handleNumberDelete (event) {
let flag = false
let isRawValEmpty = false
if (this.curValue === '') {
flag = true
isRawValEmpty = true
this.curValue = this.initialControlValue === undefined ? this.max : Math.min(this.initialControlValue, this.max)
}
const curNumberValue = Number(this.curValue)
if (curNumberValue - 1 >= this.min) {
const curLenAfterDot = (String(curNumberValue) || '').split('.')[1] || ''
let newVal = flag ? curNumberValue : curNumberValue - 1
let newVal = isRawValEmpty ? curNumberValue : curNumberValue - 1
if (typeof this.precision !== 'undefined') {
newVal = this.handleToFixed(newVal, Math.min(16, Math.max(curLenAfterDot.length, this.precision)))
}
Expand All @@ -613,15 +613,15 @@ export default {
}
},
handleNumberAdd (event) {
let flag = false
let isRawValEmpty = false
if (this.curValue === '') {
flag = true
isRawValEmpty = true
this.curValue = this.initialControlValue === undefined ? this.min : Math.max(this.initialControlValue, this.min)
}
const curNumberValue = Number(this.curValue)
if (curNumberValue <= this.max - 1) {
const curLenAfterDot = (String(curNumberValue) || '').split('.')[1] || ''
let newVal = flag ? curNumberValue : curNumberValue + 1
let newVal = isRawValEmpty ? curNumberValue : curNumberValue + 1
if (typeof this.precision !== 'undefined') {
newVal = this.handleToFixed(newVal, Math.min(16, Math.max(curLenAfterDot.length, this.precision)))
}
Expand Down

0 comments on commit 1fd9c7b

Please sign in to comment.