Back to Ant Design

Statistic

components/statistic/index.zh-CN.md

6.3.73.6 KB
Original Source

何时使用 {#when-to-use}

  • 当需要突出某个或某组数字时。
  • 当需要展示带描述的统计类数据时使用。

代码演示 {#examples}

<!-- prettier-ignore -->

<code src="./demo/basic.tsx">基本</code> <code src="./demo/unit.tsx">单位</code> <code src="./demo/animated.tsx">动画效果</code> <code src="./demo/card.tsx" background="grey">在卡片中使用</code> <code src="./demo/timer.tsx" version="5.25.0">计时器</code> <code src="./demo/style-class.tsx" version="6.0.0">自定义语义结构的样式和类</code> <code src="./demo/component-token.tsx" debug>组件 Token</code>

API

通用属性参考:通用属性

Statistic

参数说明类型默认值版本
classNames用于自定义 Statistic 组件内部各语义化结构的 class,支持对象或函数Record<SemanticDOM, string> | (info: { props }) => Record<SemanticDOM, string>-
decimalSeparator设置小数点string.
formatter自定义数值展示(value) => ReactNode-
groupSeparator设置千分位标识符string,
loading数值是否加载中booleanfalse4.8.0
precision数值精度number-
prefix设置数值的前缀ReactNode-
styles用于自定义 Statistic 组件内部各语义化结构的行内 style,支持对象或函数Record<SemanticDOM , CSSProperties> | (info: { props }) => Record<SemanticDOM , CSSProperties>-
suffix设置数值的后缀ReactNode-
title数值的标题ReactNode-
value数值内容string | number-
valueStyle设置数值区域的样式,请使用 styles.content 替代CSSProperties-

Statistic.Countdown <Badge type="error">Deprecated</Badge>

<Antd component="Alert" title="版本 >= 5.25.0 时请使用 Statistic.Timer 作为替代方案。" type="warning" banner="true"></Antd>

<!-- prettier-ignore -->
参数说明类型默认值版本
format格式化倒计时展示,参考 dayjsstringHH:mm:ss
prefix设置数值的前缀ReactNode-
suffix设置数值的后缀ReactNode-
title数值的标题ReactNode-
value数值内容number-
valueStyle设置数值区域的样式CSSProperties-
onFinish倒计时完成时触发() => void-
onChange倒计时时间变化时触发(value: number) => void-

Statistic.Timer <Badge>5.25.0+</Badge>

参数说明类型默认值版本
type计时类型,正计时或者倒计时countdown countup-
format格式化倒计时展示,参考 dayjsstringHH:mm:ss
prefix设置数值的前缀ReactNode-
suffix设置数值的后缀ReactNode-
title数值的标题ReactNode-
value数值内容number-
valueStyle设置数值区域的样式CSSProperties-
onFinish倒计时完成时触发, 指定为 countup 此属性不生效() => void-
onChange倒计时时间变化时触发(value: number) => void-

Semantic DOM

<code src="./demo/_semantic.tsx" simplify="true"></code>

主题变量(Design Token){#design-token}

<ComponentTokenTable component="Statistic"></ComponentTokenTable>