小编spe*_*ius的帖子

Intl.NumberFormat "compact" 没有返回格式正确的数字

按照这个例子,我试图让大数字格式化得更紧凑:

console.log(
    new Intl.NumberFormat(
        'en-GB', 
        { notation: "compact" , compactDisplay: "short" }
    ).format(987654321)
);
Run Code Online (Sandbox Code Playgroud)

但是我在 Firefox 和 Chrome 中的结果不同。我得到“987,654,321”而不是示例中预期的“988M”。任何人都知道为什么会这样以及我如何解决它?

firefox google-chrome number-formatting ecmascript-6

5
推荐指数
1
解决办法
648
查看次数