js格式化文件大小
const sizeUnit = ['Bytes', 'KB', 'MB', 'GB', 'TB']; function formatSize(fileSizeInBytes) { const sizeType = parseInt( Math.floor(Math.log(fileSizeInBytes) / Math.log(1024)).toString(), ); console.log('sizeType', sizeType); const size = (fileSizeInBytes / Math.pow(1024, sizeType)).toFixed(2); return size + sizeUnit[sizeType]; }