js文件大小格式化
function formatFileSize(bytes, decimalPoint = 2) {
if (bytes == 0) return "0 Bytes";
let k = 1000,
sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"],
i = Math.floor(Math.log(bytes) / Math.log(k));
return (
parseFloat((bytes / Math.pow(k, i)).toFixed(decimalPoint)) + " " + sizes[i]
);
}

浙公网安备 33010602011771号