<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
</body>
<script>
// 数字转换
var numberFormat = function (value) {
var param = {};
var k = 10000,
sizes = ['', '万', '亿', '万亿'],
i;
if(value < k){
param.value =value
param.unit=''
}else{
i = Math.floor(Math.log(value) / Math.log(k));
param.value = ((value / Math.pow(k, i))).toFixed(2);
param.unit = sizes[i];
}
return param;
}
console.log(numberFormat(15222256.33))
</script>
</html>