Skip to content

Conversation

aaamrh
Copy link

@aaamrh aaamrh commented Sep 11, 2025

Types of changes

  • New feature
  • Bug fix
  • Enhancement
  • Component style change
  • Typescript definition change
  • Documentation change
  • Coding style change
  • Refactoring
  • Test cases
  • Continuous integration
  • Breaking change
  • Others

Background and context

input number 组件输入小数会变成科学计数法,0.000000001 -> 1e-8 , 这是机器影响用户体验。
并且 react 版本并不存在这个问题。
经过搜索发现早期 arco-design-vue是修复过这个问题的 arco-design/arco-design#865

问题复现路径:
在文档中就能复现
image

Solution

  • 新增 toSafeString 工具函数来处理科学计数法转换

  • 修改 getStringValue 函数,使用 toSafeString 替代原生的 String() 方法

  • 使用 number-precision 库确保精确的数值转换

  • 📁 packages/web-vue/components/input-number/utils.ts - 新增工具函数

  • 📁 packages/web-vue/components/input-number/input-number.tsx - 修改核心逻辑

  • 📁 packages/web-vue/components/input-number/__test__/index.test.ts - 添加测试用例

How is the change tested?

添加并通过了组件测试用例。

1.234e5 => 123400

-0.000000000000000000001 => -0.000000000000000000001
等,具体文件在 packages/web-vue/components/input-number/test/index.test.ts`

Changelog

Component Changelog(CN) Changelog(EN) Related issues
InputNumber InputNumber 组件始终使用非科学计数法展示数值。 The InputNumber component always displays numbers in non-scientific notation. #3599

Checklist:

  • Test suite passes (npm run test)
  • Provide changelog for relevant changes (e.g. bug fixes and new features) if applicable.
  • Changes are submitted to the appropriate branch (e.g. features should be submitted to feature branch and others
    should be submitted to main branch)

Copy link

codesandbox bot commented Sep 11, 2025

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants