Intl.DisplayNames.prototype.resolvedOptions() method returns a new object with properties reflecting the locale and style formatting options computed during the construction of the current DisplayNames 对象。

句法

displayNames.resolvedOptions()
					

返回值

An object with properties reflecting the locale and formatting options computed during the construction of the given DisplayNames 对象。

描述

The object returned by resolvedOptions() has the following properties:

locale
The BCP 47 language tag for the locale actually used. If any Unicode extension values were requested in the input BCP 47 language tag that led to this locale, the key-value pairs that were requested and are supported for this locale are included in locale .
style
The value provided for this property in the options argument of the constructor or the default value ( "long" ). Its value is either "long" , "short" ,或 "narrow" .
type
The value provided for this property in the options argument of the constructor or the default value ( "language" ). Its value is either "language" , "region" , "script" ,或 "currency" .
fallback
The value provided for this property in the options argument of the constructor or the default value ( "code" ). Its value is either "code" or "none" .

范例

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"
					

规范

规范
Intl.DisplayNames
The definition of 'resolvedOptions()' in that specification.

浏览器兼容性

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
resolvedOptions Chrome 81 Edge 81 Firefox No IE No Opera 68 Safari No WebView Android 81 Chrome Android 81 Firefox Android No Opera Android 58 Safari iOS No Samsung Internet Android No nodejs 14.0.0

图例

完整支持

完整支持

不支持

不支持

另请参阅

元数据

  • 最后修改: