Skip to content
On this page

wm-kit / Exports / formatPrice

Function: formatPrice

formatPrice(price, config?): string

金额格式化

Parameters

NameTypeDescription
pricestring | number需要格式化的金额 类型为number | string
config?IFormatPriceConfig格式化配置 包含金额符号 小数点符号 分割符号

Returns

string

格式后的金额 字符串类型

示例:

ts
import { formatPrice } from 'wm-kit'
formatPrice(123220, { symbol: '¥', decimal: '.', separator: ',' } // => ¥123,220.00
formatPrice(123220, { decimal: '.', separator: ',' } // => 123,220.00
formatPrice(123220, {  separator: '-' } // => 123-220.00
formatPrice(123220) // => 123220.00

Author

曹海

Defined in

src/modules/price/index.ts:154

Released under the MIT License.