Intl.ListFormat.prototype.resolvedOptions()

Baseline 已广泛支持

此特性已得到良好支持,可在多种设备和浏览器版本上使用。自 2021 年 4 月起,所有浏览器均已支持此特性。

resolvedOptions() 方法是 Intl.ListFormat 实例的一个方法,它返回一个新对象,其中包含在初始化此 ListFormat 对象期间计算的选项的属性。

试一试

const deListFormatter = new Intl.ListFormat("de-DE", { type: "disjunction" });
const options = deListFormatter.resolvedOptions();

console.log(options.locale);
// Expected output: "de-DE"

console.log(options.style);
// Expected output: "long"

console.log(options.type);
// Expected output: "disjunction"

语法

js
resolvedOptions()

参数

无。

返回值

一个新对象,其中包含在初始化此 ListFormat 对象期间计算的选项的属性。该对象具有以下属性,按列出顺序排列:

locale

区域设置协商过程确定的实际使用的区域设置的 BCP 47 语言标记。输出中不包含 Unicode 扩展键。

type

options 参数中为此属性提供的值,并根据需要填充默认值。它可以是 "conjunction"(连词)、"disjunction"(选择)或 "unit"(单位)。默认值为 "conjunction"

style

options 参数中为此属性提供的值,并根据需要填充默认值。它可以是 "long"(长)、"short"(短)或 "narrow"(极短)。默认值为 "long"

示例

使用 resolvedOptions

js
const deListFormatter = new Intl.ListFormat("de-DE", { style: "short" });

const usedOptions = de.resolvedOptions();
console.log(usedOptions.locale); // "de-DE"
console.log(usedOptions.style); // "short"
console.log(usedOptions.type); // "conjunction" (the default value)

规范

规范
ECMAScript® 2026 国际化 API 规范
# sec-Intl.ListFormat.prototype.resolvedoptions

浏览器兼容性

另见