vue-i18n / general / ComposerDateTimeFormatting
接口:ComposerDateTimeFormatting()<DateTimeFormats, Locales, DefinedDateTimeFormat, C, M, ResourceKeys>
日期时间格式化函数
备注
这是 Composer 的接口
Vue I18n 组合式 API
类型参数
| 类型参数 | 默认类型 |
|---|---|
DateTimeFormats extends Record<string, any> | object |
Locales | "en-US" |
DefinedDateTimeFormat extends RemovedIndexResources<DefineDateTimeFormat> | RemovedIndexResources<DefineDateTimeFormat> |
C | IsEmptyObject<DefinedDateTimeFormat> extends false ? PickupFormatPathKeys<{ [K in keyof DefinedDateTimeFormat]: DefinedDateTimeFormat[K] }> : never |
M | IsEmptyObject<DateTimeFormats> extends false ? PickupFormatKeys<DateTimeFormats> : never |
ResourceKeys extends C | M | IsNever<C> extends false ? IsNever<M> extends false ? C | M : C : IsNever<M> extends false ? M : never |
调用签名
ts
ComposerDateTimeFormatting(value): string;日期时间格式化
参数
| 参数 | 类型 | 描述 |
|---|---|---|
value | string | number | Date | 值、时间戳数字或 Date 实例或 ISO 8601 字符串 |
返回值
string
格式化后的值
备注
如果在响应式上下文中使用,当语言环境更改时它将重新计算。
如果使用 useI18nScope 'local' 或在 useI18n 中指定了某些 UseI18nOptions,则优先在本地作用域的日期时间格式中进行翻译,而不是全局作用域的日期时间格式。
否则,它将使用全局作用域的日期时间格式进行格式化。
请参见:
调用签名
ts
ComposerDateTimeFormatting<Value, Key, OptionsType>(value, keyOrOptions): IsPart<OptionsType> extends true ? DateTimeFormatPart[] : string;日期时间格式化
类型参数
| 类型参数 | 默认类型 |
|---|---|
Value extends string | number | Date | number |
Key extends string | string |
OptionsType | | ResourceKeys | Key | DateTimeOptions<ResourceKeys | Key, Locales> |
参数
| 参数 | 类型 | 描述 |
|---|---|---|
value | Value | 值、时间戳数字或 Date 实例或 ISO 8601 字符串 |
keyOrOptions | OptionsType | 日期时间格式的键,或用于日期时间格式化的附加 选项 |
返回值
IsPart<OptionsType> extends true ? DateTimeFormatPart[] : string
格式化后的值
备注
重载的 d。
在此重载的 d 中,对已注册在日期时间格式中的键进行日期时间格式化。
调用签名
ts
ComposerDateTimeFormatting<Value, Key, OptionsType>(
value,
keyOrOptions,
locale): IsPart<OptionsType> extends true ? DateTimeFormatPart[] : string;日期时间格式化
类型参数
| 类型参数 | 默认类型 |
|---|---|
Value extends string | number | Date | number |
Key extends string | string |
OptionsType | | ResourceKeys | Key | DateTimeOptions<ResourceKeys | Key, Locales> |
参数
| 参数 | 类型 | 描述 |
|---|---|---|
value | Value | 值、时间戳数字或 Date 实例或 ISO 8601 字符串 |
keyOrOptions | OptionsType | 日期时间格式的键,或用于日期时间格式化的附加 选项 |
locale | Locales | 语言环境,它将覆盖全局作用域或局部作用域。 |
返回值
IsPart<OptionsType> extends true ? DateTimeFormatPart[] : string
格式化后的值
备注
重载的 d。
在此重载的 d 中,对目标语言环境中已注册的日期时间格式键进行日期时间格式化。