Intl.RelativeTimeFormat.prototype.resolvedOptions()
method returns a new object with properties reflecting the locale and relative time formatting options computed during initialization of this
RelativeTimeFormat
对象。
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
relativeTimeFormat.resolvedOptions()
A new object with properties reflecting the locale and number formatting options computed during the initialization of the given
RelativeTimeFormat
对象。
The resulting object has the following properties:
locale
locale
.
style
"long"
(default, e.g.,
in 1 month
)
"short"
(e.g.,
in 1 mo.
),
"narrow"
(e.g.,
in 1 mo.
). The narrow style could be similar to the short style for some locales.
numeric
"always"
(default, e.g.,
1 day ago
),
"auto"
(e.g.,
yesterday
). The
"auto"
value allows to not always have to use numeric values in the output.
numberingSystem
"nu"
or filled in as a default.
resolvedOptions
方法
var de = new Intl.RelativeTimeFormat('de-DE');
var usedOptions = de.resolvedOptions();
usedOptions.locale; // "de-DE"
usedOptions.style; // "long"
usedOptions.numeric; // "always"
usedOptions.numberingSystem; // "latn"
| 规范 | 状态 | 注释 |
|---|---|---|
|
ECMAScript 国际化 API (ECMA-402)
The definition of 'RelativeTimeFormat.resolvedOptions()' in that specification. |
Stage 4 |
| Desktop | Mobile | Server | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
resolvedOptions
|
Chrome 71 | Edge 79 | Firefox 65 | IE No | Opera 58 | Safari No | WebView Android 71 | Chrome Android 71 | Firefox Android 65 | Opera Android 50 | Safari iOS No | Samsung Internet Android 10.0 |
nodejs
12.0.0
|
numberingSystem
|
Chrome 73 | Edge 79 | Firefox 70 | IE No | Opera 60 | Safari No | WebView Android 73 | Chrome Android 73 | Firefox Android No | Opera Android 52 | Safari iOS No | Samsung Internet Android No | nodejs 12.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()