fix(components): [input-number] increase and decrease error (#10067)

fix(components): [input-number]  increase and decrease error (#10063)
This commit is contained in:
jarven 2022-10-27 15:11:29 +08:00 committed by GitHub
parent b3be81dc50
commit a8c6df5958
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -182,14 +182,14 @@ const ensurePrecision = (val: number, coefficient: 1 | -1 = 1) => {
} }
const increase = () => { const increase = () => {
if (props.readonly || inputNumberDisabled.value || maxDisabled.value) return if (props.readonly || inputNumberDisabled.value || maxDisabled.value) return
const value = props.modelValue || 0 const value = Number(displayValue.value) || 0
const newVal = ensurePrecision(value) const newVal = ensurePrecision(value)
setCurrentValue(newVal) setCurrentValue(newVal)
emit(INPUT_EVENT, data.currentValue) emit(INPUT_EVENT, data.currentValue)
} }
const decrease = () => { const decrease = () => {
if (props.readonly || inputNumberDisabled.value || minDisabled.value) return if (props.readonly || inputNumberDisabled.value || minDisabled.value) return
const value = props.modelValue || 0 const value = Number(displayValue.value) || 0
const newVal = ensurePrecision(value, -1) const newVal = ensurePrecision(value, -1)
setCurrentValue(newVal) setCurrentValue(newVal)
emit(INPUT_EVENT, data.currentValue) emit(INPUT_EVENT, data.currentValue)