Skip to content

Commit

Permalink
fix: 修复stepper不能输入小数的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
三少 committed May 9, 2022
1 parent 713d274 commit 40a192c
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions packages/vantui/src/stepper/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,14 @@ export function Stepper(props: StepperProps) {
const _format = useCallback(
(value) => {
value = _filter(value)
// format range
value = value === '' ? 0 : +value
value = Math.max(Math.min(+max, value), +min)
// format decimal
if (isDef(decimalLength)) {
value = value.toFixed(decimalLength)
if (!/(.+?)\.$/.test(String(value))) {
// format range
value = value === '' ? 0 : +value
value = Math.max(Math.min(+max, value), +min)
// format decimal
if (isDef(decimalLength)) {
value = value.toFixed(decimalLength)
}
}
return value
},
Expand Down

0 comments on commit 40a192c

Please sign in to comment.