js保留兩位小數點,是0沒有小數點!


//價格處理, 多個地方用到
export const getAfterDotNums=(value)=>{
let len = 0;
let newValue = value.toString();
if (value.toString().indexOf('.') > -1) {
len = value.toString().split(".")[1].length;
}
switch (len) {
case 0:
newValue += '.00';
break;
case 1:
newValue += '0';
break;
default:
}
return newValue;
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM