原文出自:https://blog.csdn.net/seesun2012

//  格式化文件大小
function renderSize(value){
    if(null==value||value==''){
        return "0 Bytes";
    }
    var unitArr = new Array("Bytes","KB","MB","GB","TB","PB","EB","ZB","YB");
    var index=0,
        srcsize = parseFloat(value);
 index=Math.floor(Math.log(srcsize)/Math.log(1024));
    var size =srcsize/Math.pow(1024,index);
    //  保留的小数位数
    size=size.toFixed(2);
    return size+unitArr[index];
}

相关文章:

  • 2021-05-22
  • 2021-09-08
  • 2022-03-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-01
猜你喜欢
  • 2021-06-01
  • 2021-12-10
  • 2021-10-08
  • 2022-12-23
  • 2021-12-12
  • 2021-07-02
  • 2022-12-23
相关资源
相似解决方案