[英]how to convert 4 decimal string to 2 decimal string in typescript
我得到這樣的價值。
data[0].percentage='0.0000'
我希望這個值為 =
'0.00'
如何轉換
“0.0000”到“0.00”
我試過了
parseFloat(data[0].percentage).toFixed(2)
我得到NaN
const percentage = '0.0000'; console.log(Number(percentage).toFixed(2));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.