亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Intl.NumberFormat:貨幣和數字的區別

Intl.NumberFormat:貨幣和數字的區別

九州編程 2023-08-18 16:36:53
為什么使用 style: 'currency' 時 Intl.NumberFormat 的輸出與僅格式化常規數字時不同?由于某種原因,當格式化為貨幣時,它在使用相同的區域設置時使用不同的逗號分隔符規則。console.log(new Intl.NumberFormat('en-BE').format(2222.22))// 2.222,22console.log(new Intl.NumberFormat('en-BE', {  currency: 'EUR',  style: 'currency'}).format(2222.22))// €2,222.22 -> I expect €2.222,22
查看完整描述

1 回答

?
蕭十郎

TA貢獻1815條經驗 獲得超13個贊

使用 en-DE 也會遇到同樣的問題

如果您想要歐洲格式,請使用有效的區域設置。

  • nl_NL、nl-BE、de-BE (€ 2,222.22)

  • fr-BE (2 222,22 €)

console.log(new Intl.NumberFormat('nl-NL').format(2222.22))

// 2.222,22


const opts = {

  currency: 'EUR',

  style: 'currency'

}


console.log(new Intl.NumberFormat('nl-NL', opts).format(2222.22))

// € 2.222,22 


console.log(new Intl.NumberFormat('fr-BE', opts).format(2222.22))

// 2 222,22 €


查看完整回答
反對 回復 2023-08-18
  • 1 回答
  • 0 關注
  • 111 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號