Elements

组件

格式化 Format

Format:格式化组件。用 Intl 格式化数字、货币、字节和相对时间。部件:Number、Byte、Time、RelativeTime。

#基础用法

format/basic Vue React
12,345.671.54 MB09:308 months ago

#属性

#Byte

属性类型默认值描述
unit'bit' | 'byte'显示字节时使用的单位粒度
unitDisplay'long' | 'short' | 'narrow'单位的显示方式
unitSystem'decimal' | 'binary'格式化使用的单位制
valuenumber要格式化的字节数

#Number

属性类型默认值描述
compactDisplay'short' | 'long' | undefined—
currencyDisplaystring | undefined—
currencySignstring | undefined—
notation'standard' | 'scientific' | 'engineering' | 'compact' | undefined—
signDisplay'auto' | 'never' | 'always' | 'exceptZero' | undefined—
unitstring | undefined—
unitDisplay'short' | 'long' | 'narrow' | undefined—
valuenumber要格式化的字节数

#RelativeTime

属性类型默认值描述
localeMatcherIntl.RelativeTimeFormatLocaleMatcher区域设置匹配算法;详情见 Intl 文档(https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_negotiation)
numericIntl.RelativeTimeFormatNumeric输出消息的格式
styleIntl.RelativeTimeFormatStyle国际化消息的长度
valueDate要格式化的日期

#Time

属性类型默认值描述
valuestring | Date要格式化的时间