描述
數字系統是表達數字的系統。有關支援的數字系統型別的列表,請參閱 Intl.supportedValuesOf()。
numberingSystem 屬性的值在構造時設定,可以透過區域設定識別符號中的 nu 鍵,也可以透過 Intl.Locale() 建構函式中的 numberingSystem 選項進行設定。如果兩者都存在,後者優先;如果兩者都不存在,則該屬性的值為 undefined。
numberingSystem 的設定訪問器為 undefined。您不能直接更改此屬性。
示例
與其他區域設定子標記一樣,數字系統型別可以透過區域設定字串或建構函式的配置物件引數新增到 Intl.Locale 物件中。
透過區域設定字串新增數字系統
在 Unicode 區域設定字串規範中,numberingSystem 是一個“擴充套件子標記”。這些子標記新增有關區域設定的額外資料,並透過 -u 擴充套件鍵新增到區域設定識別符號中。要將數字系統型別新增到傳遞到 Intl.Locale() 建構函式的初始區域設定識別符號字串中,請先新增 -u 擴充套件鍵(如果它不存在)。接下來,新增 -nu 擴充套件以表明您正在新增一個數字系統。最後,新增數字系統型別。
js
const locale = new Intl.Locale("fr-Latn-FR-u-nu-mong");
console.log(locale.numberingSystem); // "mong"
透過配置物件引數新增數字系統
Intl.Locale() 建構函式有一個可選的配置物件引數,其中可以包含多種擴充套件型別,包括數字系統型別。將配置物件的 numberingSystem 屬性設定為您想要的數字系統型別,然後將其傳遞給建構函式。
js
const locale = new Intl.Locale("en-Latn-US", { numberingSystem: "latn" });
console.log(locale.numberingSystem); // "latn"
規範
| 規範 |
|---|
| ECMAScript® 2026 國際化 API 規範 # sec-Intl.Locale.prototype.numberingSystem |
瀏覽器相容性
載入中…