Skip to content
On this page

money

金额转换工具

amountSeparator

示例代码
ts
import { amountSeparator } from '@jsxiaosi/utils';

amountSeparator(123456789) // 123,456,789

参数:

参数说明类型
amount金额string / number

返回类型:string

formatDecimal

示例代码
ts
import { formatDecimal } from '@jsxiaosi/utils';

formatDecimal(12345.6789,2) // 12345.67

参数:

参数说明类型
amount金额string / number
decimalPlaces位数number

返回类型:string

centsToYuan

示例代码
ts
import { centsToYuan } from '@jsxiaosi/utils';

centsToYuan(1234567) // 12345.67

参数:

参数说明类型
amount金额string / number

返回类型:number

yuanToCents

示例代码
ts
import { yuanToCents } from '@jsxiaosi/utils';

yuanToCents(12345.67) // 1234567

参数:

参数说明类型
amount金额string / number

返回类型:number

toChineseUpper

示例代码
ts
import { toChineseUpper } from '@jsxiaosi/utils';

toChineseUpper(12345.67) // 壹万贰仟叁佰肆拾伍元陆角柒分

参数:

参数说明类型
amount金额string / number

返回类型:string