Intl.RelativeTimeFormat.prototype.resolvedOptions()
Intl.RelativeTimeFormat 实例的 resolvedOptions() 方法返回一个新对象,其属性反映了在此 Intl.RelativeTimeFormat 对象初始化期间计算的区域设置和相对时间格式选项。
¥The resolvedOptions() method of Intl.RelativeTimeFormat instances returns a new object with properties reflecting the locale and relative time formatting options computed during initialization of this Intl.RelativeTimeFormat object.
Try it
语法
参数
返回值
¥Return value
一个新对象,其属性反映在给定 Intl.RelativeTimeFormat 对象初始化期间计算的区域设置和数字格式选项。
¥A new object with properties reflecting the locale and number formatting options computed during the initialization of the given Intl.RelativeTimeFormat object.
描述
¥Description
生成的对象具有以下属性:
¥The resulting object has the following properties:
locale-
实际使用的区域设置的 BCP 47 语言标记。如果在导致此区域设置的输入 BCP 47 语言标记中请求了任何 Unicode 扩展值,则此区域设置所请求和支持的键值对将包含在
locale中。 style-
国际化消息的长度。可能的值为:
"long"(默认值,例如in 1 month)"short"(例如,in 1 mo.),- 或
"narrow"(例如in 1 mo.)。对于某些语言环境,窄样式可能类似于短样式。
numeric-
输出消息的格式。可能的值为:
"always"(默认,例如1 day ago),- 或
"auto"(例如yesterday)。"auto"值允许不必总是在输出中使用数值。
numberingSystem-
使用 Unicode 扩展键
"nu"请求的值或作为默认值填写。
示例
使用 resolvedOptions()方法
规范
| Specification |
|---|
| ECMAScript Internationalization API Specification # sec-intl.relativetimeformat.prototype.resolvedoptions |
浏览器兼容性
BCD tables only load in the browser
也可以看看
¥See also