跳到主要内容

方法

2023年10月07日
柏拉文
越努力,越幸运

一、Intl.NumberFormat.prototype.format()


1.1 认识

1.2 语法

const numberFormat = new Intl.NumberFormat();
const str = numberFormat.format(number);

1.3 场景

  • 场景一、千分位

    function formatThousands(value){
    return new Intl.NumberFormat("en-us").format(value);
    }

    const value = "2443434.3432432";
    console.log(formatThousands(value));

二、Intl.NumberFormat.prototype.formatRange()


三、Intl.NumberFormat.prototype.formatRangeToParts()


四、Intl.NumberFormat.prototype.formatToParts()


五、Intl.NumberFormat.prototype.resolvedOptions()


六、Intl.NumberFormat.supportedLocalesOf()