Intl.NumberFormat 重新格式化货币符号

问题描述 投票:0回答:2

我正在使用 JS 的 Intl.Numberformat 函数,但是有没有办法可以替换现在的输出: ANG12.45 格式为:fl。 12.45 因此,将默认的currencyDisplay 替换为自定义命名,包括符号和值之间的空格?

value = parseFloat(value);
var formatter = new Intl.NumberFormat('en-US', {
    style: 'currency',
    currency: 'ANG', 
    currencyDisplay: 'symbol',
    minimumFractionDigits: 2
});
return formatter.format(value);
javascript currency number-formatting
2个回答
8
投票
return formatter.format(value).replace("ANG", "ƒ ");

0
投票

这不能用

Intl.NumberFormat
对象来完成,因为“currency”参数的值必须在 ISO 4217 货币代码列表中,并且那里没有“FL”。

© www.soinside.com 2019 - 2024. All rights reserved.