Intl.Locale.prototype.numeric property is an accessor property that returns whether the locale has special collation handling for numeric characters.

描述

Intl.Locale.caseFirst , numeric represents a modification to the collation rules utilized by the locale. numeric 布尔 value, which means that it can be either true or false 。若 numeric is set to false , there will be no special handling of numeric values in strings. If numeric is set to true , then the locale will take numeric characters into account when collating strings. This special numeric handling means that sequences of decimal digits will be compared as numbers. For example, the string "A-21" will be considered less than "A-123".

范例

设置 numeric value via the locale string

Unicode locale string spec , the values that numeric represents correspond to the key kn . kn is considered a locale string "extension subtag". These subtags add additional data about the locale, and are added to locale identifiers by using the -u extension key. Thus, the numeric value can be added to the inital locale identifier string that is passed into the Locale constructor. To set the numeric value, first add the -u extension key to the string. Next, add the -kn extension key to indicate that you are adding a value for numeric . Finally, add the numeric value to the string. If you want to set numeric to true , simply adding the kn key will suffice. To set the value to false , you must specify in by adding " false " after the kn key.

let numericViaStr = new Intl.Locale("fr-Latn-FR-u-kn-false");
console.log(numericStr.numeric); // Prints "false"
					

设置 numeric value via the configuration object argument

Intl.Locale constructor has an optional configuration object argument, which can be used to pass extension types. Set the numeric property of the configuration object to your desired numeric value and pass it into the constructor.

let numericViaObj= new Intl.Locale("en-Latn-US", {numeric: true});
console.log(us12hour.numeric); // Prints "true"
					

规范

规范
ECMAScript 国际化 API (ECMA-402)

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
Desktop Mobile Server
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet Node.js
numeric Chrome 74 Edge 79 Firefox 75 IE No Opera 62 Safari 14 WebView Android 74 Chrome Android 74 Firefox Android No Opera Android 53 Safari iOS 14 Samsung Internet Android 11.0 nodejs 12.0.0
12.0.0
Before version 13.0.0, only the locale data for en-US is available by default. See the Locale() 构造函数 了解更多细节。

图例

完整支持

完整支持

不支持

不支持

见实现注意事项。

另请参阅

元数据

  • 最后修改: