这里是文章模块栏目内容页
存储单位换算字节计算成各种大小
/**
 * 存储单位换算
 * @param {*} bytes  
 */
export const byte = (bytes) => {
    if (bytes === 0) return '0 B';
    var k = 1000, // or 1024
        sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
        i = Math.floor(Math.log(bytes) / Math.log(k));

    return (bytes / Math.pow(k, i)).toPrecision(3) + ' ' + sizes[i];
}

这个是vue一个函数写法,和普通js相比,通过export 可以导出这个函数,提供给需要引入的地方;