as

Settings
Sign out
Notifications
Alexa
亚马逊应用商店
Ring
AWS
文档
Support
Contact Us
My Cases
新手入门
设计和开发
应用发布
参考
支持
跳转到主要内容
MessageFormatClassic API接受用经典的ICU MessageFormat模式来格式化消息。 MessageFormatClassic API支持模式中的命名参数样式和编号参数样式。使用命名参数样式通过提供描述性命名参数来改善开发者和翻译者的可读性。此外,这可以更好地推断出模式中的参数内包含哪种值。

构造函数

new MessageFormatClassic()

new MessageFormatClassic(): MessageFormatClassic

返回值

MessageFormatClassic

方法

format()

static format(pattern: string, args: Map<string, string | number | Date>): string | null 在默认区域设置中使用命名参数格式化指定模式。

参数

pattern
string 经典的消息格式模式。
args
Map<string, string | number | Date> 将参数名称映射到其值。成功时的格式化消息,失败时为null。

返回值

string | null

formatPositional()

static formatPositional(pattern: string, args?: (string | number | Date)[]): string | null 在默认区域设置中使用编号参数格式化指定模式。

参数

pattern
string 经典的消息格式模式。
args?
(string | number | Date)[] 参数值数组成功时的格式化消息,失败时为null。

返回值

string | null

formatPositionalWithLocale()

static formatPositionalWithLocale(pattern: string, locale: string | null, args?: (string | number | Date)[]): string | null 在指定区域设置中使用编号参数格式化指定模式。

参数

pattern
string 经典的消息格式模式。
locale
string | null BCP-47区域设置字符串。如果此参数为null或空字符串,则使用默认区域设置。
args?
(string | number | Date)[] 参数值数组成功时的格式化消息,失败时为null。

返回值

string | null

formatWithLocale()

static formatWithLocale(pattern: string, locale: string | null, args: Map<string, string | number | Date>): string | null 在指定区域设置中使用命名参数格式化指定模式。

参数

pattern
string 经典的消息格式模式。
locale
string | null BCP-47区域设置字符串。如果此参数为null或空字符串,则使用默认区域设置。
args
Map<string, string | number | Date> 将参数名称映射到其值。成功时的格式化消息,失败时为null。

返回值

string | null

getMajorVersion()

static getMajorVersion(): number 获取主版本号。主版本号。

返回值

number

getMinorVersion()

static getMinorVersion(): number 获取次版本号。次版本号。

返回值

number

getPatchVersion()

static getPatchVersion(): number 获取补丁版本号。补丁版本号。

返回值

number
最后修改于 2026年10月26日