react-intl 货币显示不带小数
react-intl currency displayed without decimals
我需要显示不带小数位的货币。我们需要货币修饰符 ($)、逗号和空格,由区域设置决定,但没有小数。
我试过将 maximumFractionDigits 设置为 0。这行得通,但删除了逗号和货币修饰符。
此外,我无法在 https://github.com/yahoo/react-intl/wiki/API#number-formatting-apis:
的文档中复制示例
formatNumber(1000, {style: 'currency', currency: 'USD'}); // ,000
我得到 1,000.00 美元。
感谢您的帮助。
原来你需要指定最小和最大小数位数,如下所示:
formatNumber(1000, {style: 'currency', currency: 'USD',
minimumFractionDigits: 0, maximumFractionDigits: 0}); // ,000
希望对您有所帮助。
我需要显示不带小数位的货币。我们需要货币修饰符 ($)、逗号和空格,由区域设置决定,但没有小数。
我试过将 maximumFractionDigits 设置为 0。这行得通,但删除了逗号和货币修饰符。
此外,我无法在 https://github.com/yahoo/react-intl/wiki/API#number-formatting-apis:
的文档中复制示例formatNumber(1000, {style: 'currency', currency: 'USD'}); // ,000
我得到 1,000.00 美元。
感谢您的帮助。
原来你需要指定最小和最大小数位数,如下所示:
formatNumber(1000, {style: 'currency', currency: 'USD',
minimumFractionDigits: 0, maximumFractionDigits: 0}); // ,000
希望对您有所帮助。