//格式化文件大小
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
;
var 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];
}
转载于:https://www.cnblogs.com/alasq/p/6277014.html
相关资源:如何换个角度使用VUE过滤器详解