unitNumber(num){ if(num==0){ return 0 } if (!num || isNaN(num)) { return '请传入数值格式的数据' } // 此处为防止字符串形式的数值进来,因为toFixed方法只能用于数值型数 num = Number(num) if (Math.abs(num) > 100000000) { return (num / 100000000).toFixed(1) + '亿' } else if (Math.abs(num) > 10000&&Math.abs(num) <10000000) { return (num / 10000).toFixed(1) + '万' } else if (Math.abs(num) > 10000000&&Math.abs(num) <100000000) { return (num / 10000000).toFixed(1) + '千万' } else { return num.toFixed(0) } },
标签:转换成,return,abs,万亿,前端,toFixed,num,100000000,Math From: https://www.cnblogs.com/dabu/p/16902506.html