Accounting.js库的使用

Accounting.js用来将一个数字格式化为货币格式
使用案例:

<!DOCTYPE html>
<html>
<head>
  <meta name="description" content="math.js | basic usage">
  <title>math.js | basic usage</title>
  <script src="accounting.js"></script>
</head>
<body>
  <script>

    // functions and constants
    //格式化为美元,默认
    print(accounting.formatMoney(45998307)); // $45,998,307.00
    //也可以指定参数
    /*
    var options={
            symbol :"$",
            decimal:".",
            thousand:",",
            precision:2,
            format:"%s%v"
        }
     */
    //欧元形式
    print(accounting.formatMoney(4587.35,"€",3,".",","));//€4.587,350
    //也可以格式化整个一列数字:
    var list =[[455,12,3],[88,25,2],[667,825,14]];
    var c = accounting.format(list);//455,12,3,88,25,2,667,825,14
    print(c);
    print(accounting.formatColumn(list));//$455.00,$ 12.00,$ 3.00,$88.00,$25.00,$ 2.00,$667.00,$825.00,$ 14.00
    // helper function to output formatted results.
    function print(value) {
      var precision = 14;
      document.write(value + '<br>');
    }
  </script>
</body>
</html>

下载网站:http://openexchangerates.github.io/accounting.js/#download

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值