偶然看到阿里界面有个
function(c, f) {
f === void 0 && (f = 2);
f (z.a.isNil(c)) return "-";
if (c.toString() === "0") return "0 B";
var o = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"],
y = 0,
G = parseFloat(c);
if (G < 0) return "-";
y = Math.floor(Math.log(G) / Math.log(1024));
var w = G / Math.pow(1024, y);
return w.toFixed(f) + " " + o[y]
},