1 //格式化文件大小 2 function renderSize(value){ 3 if(null==value||value==‘‘){ 4 return "0 Bytes"; 5 } 6 var unitArr = new Array("Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"); 7 var index=0; 8 var srcsize = parseFloat(value); 9 index=Math.floor(Math.log(srcsize)/Math.log(1024)); 10 var size =srcsize/Math.pow(1024,index); 11 size=size.toFixed(2);//保留的小数位数 12 return size+unitArr[index]; 13 }
原文地址:https://www.cnblogs.com/e-cat/p/9837545.html
时间: 2024-10-26 07:24:06