数字格式进位

moneyFormat(arg){
if(arg.toString().length>=13){
// return arg/1000000000000+"万亿"
const moneys = arg/1000000000000
const realVal = parseFloat(moneys).toFixed(2);
this.unit = "万亿"
return {num:realVal,unit:"万亿"}

}else if(arg.toString().length>=9){
const moneys = arg/100000000
const realVal = parseFloat(moneys).toFixed(2);
this.unit = "亿"
return {num:realVal,unit:"亿"}
}else if(arg.toString().length>4){
const moneys = arg/10000
const realVal = parseFloat(moneys).toFixed(2);
this.unit = "万"
return {num:realVal,unit:"万"}
} else {
return {num:arg,unit:""}
}

},
posted @ 2023-02-06 10:41  无情风中  阅读(11)  评论(0编辑  收藏  举报