vtils

Home > utils > formatNumber

formatNumber() function

格式化数字。

Signature:

export declare function formatNumber(value: number, options?: FormatNumberOptions): string;

Parameters

Parameter Type Description
value number 要格式化的数字
options FormatNumberOptions (Optional) 选项

Returns:

string

返回格式化后的数值

Example

formatNumber(1314.56789) // => '1,314.56789'
formatNumber(1314.56789, { thousandsSeparator: ' ' }) // => '1 314.56789'
formatNumber(1314.56789, { thousandthsSeparator: ',' }) // => '1,314.567,89'