js计算流量值的方法
来源:互联网 发布:python csvkit 编辑:程序博客网 时间:2024/04/28 04:51
//计算流量值( flowVlueBytes为流量的bytes字节数)
function getFlow(flowVlueBytes){
var flow = "";
//如果赠送流量小于1MB.则显示为KB
if(flowVlueBytes/1024 < 1024){
flow = (Math.round(flowVlueBytes/1024) > 0 ? Math.round(flowVlueBytes/1024) : 0) + 'KB';
}else if(flowVlueBytes/1024 >= 1024 && flowVlueBytes/1024/1024 < 1024){
//如果赠送流量大于1MB且小于1 GB的则显示为MB
flow = (Math.round(flowVlueBytes/1024/1024) > 0 ? Math.round(flowVlueBytes/1024/1024) : 0)+'MB';
}else if(flowVlueBytes/1024/1024 >= 1024){
//如果流量大于1Gb
var gb_Flow = flowVlueBytes/1024/1024/1024;
//toFixed(1);四舍五入保留一位小数
flow = gb_Flow.toFixed(1)+'GB';
}else{
flow = "0KB";
}
return flow;
}
function getFlow(flowVlueBytes){
var flow = "";
//如果赠送流量小于1MB.则显示为KB
if(flowVlueBytes/1024 < 1024){
flow = (Math.round(flowVlueBytes/1024) > 0 ? Math.round(flowVlueBytes/1024) : 0) + 'KB';
}else if(flowVlueBytes/1024 >= 1024 && flowVlueBytes/1024/1024 < 1024){
//如果赠送流量大于1MB且小于1 GB的则显示为MB
flow = (Math.round(flowVlueBytes/1024/1024) > 0 ? Math.round(flowVlueBytes/1024/1024) : 0)+'MB';
}else if(flowVlueBytes/1024/1024 >= 1024){
//如果流量大于1Gb
var gb_Flow = flowVlueBytes/1024/1024/1024;
//toFixed(1);四舍五入保留一位小数
flow = gb_Flow.toFixed(1)+'GB';
}else{
flow = "0KB";
}
return flow;
}
0 0
- js计算流量值的方法
- 流量单位的计算
- 流量计算
- 获取手机流量的方法
- 辨别网站流量来源的js语句
- js 判断计算字符串长度/判断空的简单方法
- JS中用于精确计算的加减乘除方法
- JS计算浮点数加减乘除精确数值的方法
- jQuery和JS:网页常用计算宽高的方法
- JS中一种计算任意字符串宽度的方法
- Vue.js中计算属性和方法的区别
- js计算触摸距离方法
- 浅谈博客的流量的方法
- Android提供的获取流量的方法
- 计算MD5值的方法
- 载流量计算公式
- 如何计算视频流量?
- 基于hash计算的多层实验流量切分的实现
- 安装protobuf到Ubuntu14.04
- 根据关键字选出excel中匹配的数据
- 公司或个人如何创造感情联系
- MySQL数据库定时自动备份脚本
- 各个特殊类的介绍
- js计算流量值的方法
- pll 解锁
- Android 4.2 Bluetooth 分析总结(一)
- PO表
- 黑马程序员——Java/GUI
- MongoDB Sharding
- base64加密解密
- 电脑硬件知识扫盲 菜鸟提升必看电脑配置知识
- iOS:UIWebView布局