欢迎光临散文网 会员登陆 & 注册

金币num的表现形式(t s)

2021-08-24 14:02 作者:会飞的蜗牛007  | 我要投稿

例如:900000000 返回的表现形式为:900,000,000

public static formateNum(num,addName?:string){

let prename = '';

if(addName)prename = addName;

if(num > 1000){

let tempNum = num;

let newPath = '';

while(tempNum > 1000){

let tempPath = '';

if(tempNum%1000 == 0){

tempPath = ',000';

}else{

if(tempNum%1000 < 10){

tempPath = ',00'+ tempNum%1000;

}else if(tempNum%1000 >= 10 && tempNum%1000 < 100){

tempPath = ',0'+ tempNum%1000;

}else{

tempPath = ','+ tempNum%1000;

}

}

newPath = tempPath + newPath;

tempNum = Math.floor(tempNum/1000);

}

newPath = prename + tempNum + newPath;

return newPath;


}else{

return prename+num;

}

}


金币num的表现形式(t s)的评论 (共 条)

分享到微博请遵守国家法律