npm
unpkg:https://unpkg.com/@happys/money-format@latest/dist/format.min.js
Installation
npm install @happys/money-format
or
yarn add @happys/money-format
##Usage
import { format } from '@happys/money-format';
const result = format(1234567);
console.log(result);
1,234,567.00
import { RMB } from '@happys/money-format';
const result = RMB(10010);
console.log(result);
壹万零壹拾元整
##Example
<script type="text/javascript" src="https://unpkg.com/@happys/money-format@latest/dist/format.min.js"></script>
<script>
var result = moneyFormat.format(1234567);
var rmb = moneyFormat.RMB(10010);
</script>
##Api
format(money, options)
-
money
- type: number | string
-
options
- type: {}
{
// 小数位数
// default 2
decimal?: number;
// 分割符
// default ,
delimiter?: string;
// 分位数
// default 3
digit?: number | boolean;
// 四舍五入
// default true
round?: boolean;
}
RMB(money, options)
-
money
- type: number | string
-
options
- type: {}
{
// 前缀
// default ''
prefix?: string;
// 负数字符串
// default '负'
negativeStr?: string | boolean;
// 整数字符串
// default '整'
integerStr?: string;
}