js 1000+简写为K,10000+简写为W
function numFormat(num) {
if(num >= 10000) {
num = Math.round(num/1000)/10 + 'W';
} else if (num >= 1000) {
num = Math.round(num/100)/10 + 'K';
}
return num;
}
console.log(numFormat(1000), numFormat(20001), numFormat(3000300));
本文介绍了一种JavaScript函数,用于将数字转换为带有K(千)和W(万)简写形式的字符串,提高了大数据量显示的可读性。
702

被折叠的 条评论
为什么被折叠?



