阿根廷比索 (ARS) 的货币符号似乎与美元在美国的符号完全相反。 ,
用作小数点分隔符,.
用作千位分隔符。
1121
=>$1.121,00
1000.5
=>1.000,50 美元
85.72
=>$85,72
我调查了 numeral
(npm numeral js
) 并且我无法将 float 转换为上面指定的货币格式。
这是我尝试过的:
> numeral('87.75').format('$0.0,00')
'$87.7500'
> numeral('87.75').format('$0,0.00')
'$87.75'
> numeral('87.75').format('$0,00')
'$88'
> numeral('87.75').format('$0.00')
'$87.75'
> numeral('87.75').format('$00,00')
'$88'
> numeral('87.75').format('$0.00')
'$87.75'
> numeral('87.75').format('$00,00')
'$88'
> numeral('87.75').format('$00,00.00')
'$87.75'
> numeral('87.75').format('$0[.]0.00')
'$87.8'
> numeral('87.75').format('$0[.]0[.]00')
'$87.8'
> numeral('87.75').format('$0[.]0[,]00')
'$87.75'
> numeral('87.75').format('$0[,]0[,]00')
'$88'
这些都是字符串,但不应影响格式。
最佳答案
您必须创建自己的格式。向下滚动 numeral.js 文档到“语言”部分,查看有关如何定义定界符的示例。
numeral.language('es_ar', {
delimiters: {
thousands: '.',
decimal: ','
},
currency: {
symbol: '$'
}
});
numeral.language('es_ar');
numeral(1087.76).format('$0,0.00')
> "$1.087,76"
关于javascript - 将 float 转换为货币阿根廷比索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36605965/