formatFileSize.js 238 B

1234567
  1. export default (value) => {
  2. //文件Size转换
  3. const s = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB'];
  4. const e = Math.floor(Math.log(value) / Math.log(1024));
  5. return (value / Math.pow(1024, Math.floor(e))).toFixed(2) + ' ' + s[e];
  6. };