格式化上传附件大小的方法
作者:
源大侠 | 来源:发表于
2020-12-28 09:31 被阅读0次formetFileSize: function (fileSize) {
fileSize = parseFloat(fileSize);
if (fileSize < 1024) {
return Math.round(fileSize * 100) / 100.0 + 'B';
} else if (fileSize < 1048576) {
return Math.round((fileSize / 1024) * 100) / 100.0 + 'KB';
} else if (fileSize < 1073741824) {
return Math.round((fileSize / 1048576) * 100) / 100.0 + 'MB';
} else {
return Math.round((fileSize / 1073741824) * 100) / 100.0 + 'GB';
}
}
本文标题:格式化上传附件大小的方法
本文链接:https://www.haomeiwen.com/subject/kbbgnktx.html
网友评论