mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2025-01-30 12:52:43 +08:00
fix(input-number): exception when the value is a string with precision set (#6094)
* fix(n-input-number): exception when the value is a string in precision mode * Apply suggestions from code review * Update src/input-number/src/utils.ts --------- Co-authored-by: 07akioni <07akioni2@gmail.com>
This commit is contained in:
parent
09af7eae1a
commit
01b20dd1be
@ -2,7 +2,11 @@
|
|||||||
|
|
||||||
## NEXT_VERSION
|
## NEXT_VERSION
|
||||||
|
|
||||||
`NEXT_VERSION`
|
`xxxx-xx-xx`
|
||||||
|
|
||||||
|
### Fixes
|
||||||
|
|
||||||
|
- Fix `n-input-number` Exception when the value is a string in precision mode, closes [#6091](https://github.com/tusen-ai/naive-ui/issues/6091).
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
|
@ -2,12 +2,17 @@
|
|||||||
|
|
||||||
## NEXT_VERSION
|
## NEXT_VERSION
|
||||||
|
|
||||||
`NEXT_VERSION`
|
`xxxx-xx-xx`
|
||||||
|
|
||||||
|
### Fixes
|
||||||
|
|
||||||
|
- 修复 `n-input-number` precision 模式下 value 为字符串时的异常问题,关闭 [#6091](https://github.com/tusen-ai/naive-ui/issues/6091)
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
- `n-input-number` 新增 `round` 属性,关闭 [#6097](https://github.com/tusen-ai/naive-ui/issues/6097)
|
- `n-input-number` 新增 `round` 属性,关闭 [#6097](https://github.com/tusen-ai/naive-ui/issues/6097)
|
||||||
|
|
||||||
|
|
||||||
## 2.38.2
|
## 2.38.2
|
||||||
|
|
||||||
`2024-05-03`
|
`2024-05-03`
|
||||||
|
@ -34,7 +34,7 @@ export function format (
|
|||||||
value: number | undefined | null,
|
value: number | undefined | null,
|
||||||
precision: number | undefined
|
precision: number | undefined
|
||||||
): string {
|
): string {
|
||||||
if (value === undefined || value === null) return ''
|
if (typeof value !== 'number') return ''
|
||||||
return precision === undefined ? String(value) : value.toFixed(precision)
|
return precision === undefined ? String(value) : value.toFixed(precision)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user