Tool Hub

数字格式化

预览 Intl.NumberFormat 的货币、小数、百分比和单位输出

预览 Intl.NumberFormat 选项组合的结果。比较同一数字在不同 locale、样式和位数设置下的显示,可直接复制代码使用。

覆盖

1,234,567.89

代码
new Intl.NumberFormat("en-US", {
  "style": "decimal",
  "minimumFractionDigits": 0,
  "maximumFractionDigits": 2
}).format(number)

使用方法

  1. 输入
  2. Choose a locale from the dropdown (e.g. en-US, de-DE) or type any BCP 47 tag in the override field.
  3. 选择
  4. For currency style pick a currency code; for unit style pick a unit such as kilometer-per-hour.
  5. Adjust min and max fraction digits to control decimal precision.

示例

  • 输入
  • 输入

生产环境使用前请验证输出。无担保 — 参见 条款.