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
locale
.
style
options
argument of the constructor or the default value (
"long"
). Its value is either
"long"
,
"short"
,或
"narrow"
.
type
options
argument of the constructor or the default value (
"language"
). Its value is either
"language"
,
"region"
,
"script"
,或
"currency"
.
fallback
"code"
). Its value is either
"code"
or
"none"
.
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. |
| Desktop | Mobile | Server | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
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 |
完整支持
不支持
Intl
Collator
DateTimeFormat
ListFormat
NumberFormat
PluralRules
RelativeTimeFormat
Object
Object.prototype.__defineGetter__()
Object.prototype.__defineSetter__()
Object.prototype.__lookupGetter__()
Object.prototype.__lookupSetter__()
Object.prototype.hasOwnProperty()
Object.prototype.isPrototypeOf()
Object.prototype.propertyIsEnumerable()
Object.prototype.toLocaleString()
Object.prototype.toSource()
Object.prototype.toString()
Object.prototype.valueOf()
Object.setPrototypeOf()