gpt4 book ai didi

javascript - 返回 Intl.NumberFormat 罗马尼亚列伊的正确货币

转载 作者:行者123 更新时间:2023-11-30 11:01:35 26 4
gpt4 key购买 nike

我正在尝试格式化数字并将其显示为罗马尼亚列伊的价格。

这是我的代码片段:

console.log(Intl.NumberFormat('ro-RO', {
style: 'currency',
currency: 'RON',
currencyDisplay: 'symbol',
}).format(123));

我希望它显示 123 lei 或至少 123L(根据维基百科),但我却看到 123 RON 这是货币代码而不是符号。

有没有办法使用原生 api 显示“lei”?

最佳答案

你可以这样做,通过替换 româneşti 部分。

console.log(Intl.NumberFormat('ro-RO', {
style: 'currency',
currency: 'RON',
currencyDisplay: 'name',
}).format(123).replace('românești', ''))

关于javascript - 返回 Intl.NumberFormat 罗马尼亚列伊的正确货币,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57526989/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com