Intl.DisplayNames.prototype.resolvedOptions()
Intl.DisplayNames 实例的 resolvedOptions() 方法返回一个新对象,其属性反映了在构造此 Intl.DisplayNames 对象期间计算的区域设置和样式格式选项。
¥The resolvedOptions() method of Intl.DisplayNames instances
returns a new object with properties reflecting the locale and style formatting
options computed during the construction of this Intl.DisplayNames
object.
语法
参数
返回值
¥Return value
具有反映在构造给定 Intl.DisplayNames 对象期间计算的区域设置和格式选项的属性的对象。
¥An object with properties reflecting the locale and formatting options computed during
the construction of the given Intl.DisplayNames object.
描述
¥Description
resolvedOptions() 返回的对象具有以下属性:
¥The object returned by resolvedOptions() has the following properties:
locale-
实际使用的区域设置的 BCP 47 语言标记。如果在导致此区域设置的输入 BCP 47 语言标记中请求了任何 Unicode 扩展值,则此区域设置所请求和支持的键值对将包含在
locale中。 style-
构造函数的
options参数中为此属性提供的值或默认值 ("long")。其值为"long"、"short"或"narrow"。 type-
构造函数的
options参数中为此属性提供的值或默认值 ("language")。其值为"language"、"region"、"script"或"currency"。 fallback-
构造函数的选项参数中为此属性提供的值或默认值 (
"code")。其值为"code"或"none"。
示例
使用 resolvedOptions
¥Using resolvedOptions
const displayNames = new Intl.DisplayNames(["de-DE"], { type: "region" });
const usedOptions = displayNames.resolvedOptions();
console.log(usedOptions.locale); // "de-DE"
console.log(usedOptions.style); // "long"
console.log(usedOptions.type); // "region"
console.log(usedOptions.fallback); // "code"
规范
| Specification |
|---|
| ECMAScript Internationalization API Specification # sec-Intl.DisplayNames.prototype.resolvedOptions |
浏览器兼容性
BCD tables only load in the browser
也可以看看
¥See also