关注此 example我试图让大数字格式更紧凑:
console.log(
new Intl.NumberFormat(
'en-GB',
{ notation: "compact" , compactDisplay: "short" }
).format(987654321)
);
但是我在 Firefox 和 Chrome 中的结果不同。我得到“987,654,321”而不是示例中预期的“988M”。任何人都知道为什么会这样以及我如何解决它?
最佳答案
我遇到了同样的问题,我试图寻找一个合乎逻辑的原因,然后
我找到了这个官方文档:
https://v8.dev/features/intl-numberformat#notation
正如我所理解的“紧凑”选项,它仍然没有得到完全支持
关于google-chrome - Intl.NumberFormat "compact"没有返回正确格式的数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61307654/