0
点赞
收藏
分享

微信扫一扫

精确到小数点后两位并自动补0

萧萧雨潇潇 2022-07-13 阅读 101

 

 

export const nub= (num) => {
let f_x=parseFloat(num)
if(isNaN(f_x)){
return false
}
let ff=Math.round(num*100)/100
let s_x=ff.toString()
let pos=s_x.indexOf(".")
if(pos<0){
pos=s_x.length
s_x+="."
}
while(s_x.length<=pos+2){
s_x+="0"
}
return s_x
};

举报

相关推荐

0 条评论