Statistic 统计
展示统计数据。
基础用法
突出展示某个或某组数字,如统计数值、金额、排名等,可以在数值前后增加图标、单位和标题等元素。并使用 vueuse
日活跃用户
268,500
男女比例
138
/100
总交易额
0
反馈数
562
vue
<template>
<el-row :gutter="16">
<el-col :xs="24" :sm="12" :md="6" class="text-center mb-4">
<el-statistic title="Daily active users" :value="268500" />
</el-col>
<el-col :xs="24" :sm="12" :md="6" class="text-center mb-4">
<el-statistic :value="138">
<template #title>
<div style="display: inline-flex; align-items: center">
Ratio of men to women
<el-icon style="margin-left: 4px" :size="12">
<Male />
</el-icon>
</div>
</template>
<template #suffix>/100</template>
</el-statistic>
</el-col>
<el-col :xs="24" :sm="12" :md="6" class="text-center mb-4">
<el-statistic title="Total Transactions" :value="outputValue" />
</el-col>
<el-col :xs="24" :sm="12" :md="6" class="text-center mb-4">
<el-statistic title="Feedback number" :value="562">
<template #suffix>
<el-icon style="vertical-align: -0.125em">
<ChatLineRound />
</el-icon>
</template>
</el-statistic>
</el-col>
</el-row>
</template>
<script lang="ts" setup>
import { ref } from 'vue'
import { useTransition } from '@vueuse/core'
import { ChatLineRound, Male } from '@element-plus/icons-vue'
const source = ref(0)
const outputValue = useTransition(source, {
duration: 1500,
})
source.value = 172000
</script>
隐藏源代码
Countdown 倒计时
倒计时组件,支持添加其他组件控制倒计时。
开始抢购
00:00:00
VIP 剩余时间
00:00:00
距离下个月还有
00 天 00:00:00
2025-09-01
vue
<template>
<el-row :gutter="16">
<el-col :xs="24" :sm="12" :md="8" class="text-center mb-4">
<el-countdown title="Start to grab" :value="value" />
</el-col>
<el-col :xs="24" :sm="12" :md="8" class="text-center mb-4">
<el-countdown
title="Remaining VIP time"
format="HH:mm:ss"
:value="value1"
/>
<el-button class="countdown-footer" type="primary" @click="reset">
Reset
</el-button>
</el-col>
<el-col :xs="24" :sm="12" :md="8" class="text-center mb-4">
<el-countdown format="DD [days] HH:mm:ss" :value="value2">
<template #title>
<div style="display: inline-flex; align-items: center">
<el-icon style="margin-right: 4px" :size="12">
<Calendar />
</el-icon>
Still to go until next month
</div>
</template>
</el-countdown>
<div class="countdown-footer">{{ value2.format('YYYY-MM-DD') }}</div>
</el-col>
</el-row>
</template>
<script lang="ts" setup>
import { ref } from 'vue'
import dayjs from 'dayjs'
import { Calendar } from '@element-plus/icons-vue'
const value = ref(Date.now() + 1000 * 60 * 60 * 7)
const value1 = ref(Date.now() + 1000 * 60 * 60 * 24 * 2)
const value2 = ref(dayjs().add(1, 'month').startOf('month'))
function reset() {
value1.value = Date.now() + 1000 * 60 * 60 * 24 * 2
}
</script>
<style scoped>
.countdown-footer {
margin-top: 8px;
}
</style>
隐藏源代码
提示
格式化时建议在天数范围内
Card 卡片用法
卡片用法展示,可自由组合。
日活跃用户
98,500
较昨日 24%
月活跃用户
693,700
月环比 12%
今日新增交易
72,000
较昨日 16%
vue
<template>
<el-row :gutter="16">
<el-col :xs="24" :sm="12" :md="8" class="mb-4">
<div class="statistic-card">
<el-statistic :value="98500">
<template #title>
<div style="display: inline-flex; align-items: center">
Daily active users
<el-tooltip
effect="dark"
content="Number of users who logged into the product in one day"
placement="top"
>
<el-icon style="margin-left: 4px" :size="12">
<Warning />
</el-icon>
</el-tooltip>
</div>
</template>
</el-statistic>
<div class="statistic-footer">
<div class="footer-item">
<span>than yesterday</span>
<span class="green">
24%
<el-icon>
<CaretTop />
</el-icon>
</span>
</div>
</div>
</div>
</el-col>
<el-col :xs="24" :sm="12" :md="8" class="mb-4">
<div class="statistic-card">
<el-statistic :value="693700">
<template #title>
<div style="display: inline-flex; align-items: center">
Monthly Active Users
<el-tooltip
effect="dark"
content="Number of users who logged into the product in one month"
placement="top"
>
<el-icon style="margin-left: 4px" :size="12">
<Warning />
</el-icon>
</el-tooltip>
</div>
</template>
</el-statistic>
<div class="statistic-footer">
<div class="footer-item">
<span>month on month</span>
<span class="red">
12%
<el-icon>
<CaretBottom />
</el-icon>
</span>
</div>
</div>
</div>
</el-col>
<el-col :xs="24" :sm="12" :md="8" class="mb-4">
<div class="statistic-card">
<el-statistic :value="72000" title="New transactions today">
<template #title>
<div style="display: inline-flex; align-items: center">
New transactions today
</div>
</template>
</el-statistic>
<div class="statistic-footer">
<div class="footer-item">
<span>than yesterday</span>
<span class="green">
16%
<el-icon>
<CaretTop />
</el-icon>
</span>
</div>
<div class="footer-item">
<el-icon :size="14">
<ArrowRight />
</el-icon>
</div>
</div>
</div>
</el-col>
</el-row>
</template>
<script lang="ts" setup>
import {
ArrowRight,
CaretBottom,
CaretTop,
Warning,
} from '@element-plus/icons-vue'
</script>
<style scoped>
:global(h2#card-usage ~ .example .example-showcase) {
background-color: var(--el-fill-color) !important;
}
.el-statistic {
--el-statistic-content-font-size: 28px;
}
.statistic-card {
height: 100%;
padding: 20px;
border-radius: 4px;
background-color: var(--el-bg-color-overlay);
}
.statistic-footer {
display: flex;
justify-content: space-between;
align-items: center;
flex-wrap: wrap;
font-size: 12px;
color: var(--el-text-color-regular);
margin-top: 16px;
}
.statistic-footer .footer-item {
display: flex;
justify-content: space-between;
align-items: center;
}
.statistic-footer .footer-item span:last-child {
display: inline-flex;
align-items: center;
margin-left: 4px;
}
.green {
color: var(--el-color-success);
}
.red {
color: var(--el-color-error);
}
</style>
隐藏源代码
Statistic API
Statistic 属性
属性 | 描述 | 类型 | 默认值 |
---|---|---|---|
value | 数值内容 | number | 0 |
decimal-separator | 设置小数点 | string | . |
格式化程序 | 自定义数值展示 | Function | — |
group-separator | 设置千分位标识符 | string | , |
precision | 数值精度 | number | 0 |
prefix | 设置数值的前缀 | string | — |
suffix | 设置数值的后缀 | string | — |
title | 数字标题 | string | — |
value-style | 数字值的样式 | string / object | — |
Statistic 插槽
名称 | 描述 |
---|---|
prefix | 数值前缀 |
suffix | 数值后缀 |
title | 数字标题 |
Statistic Exposes
名称 | 描述 | 类型 |
---|---|---|
displayValue | 当前显示值 | object |
Countdown API
Countdown 属性
属性 | 描述 | 类型 | 默认值 |
---|---|---|---|
value | 目标时间 | number / Dayjs | — |
format | 格式化倒计时展示 | string | HH:mm:ss |
prefix | 设置倒计时的前缀 | string | — |
suffix | 设置倒计时的后缀 | string | — |
title | 倒计时标题 | string | — |
value-style | 倒计时的值的样式 | string / object | — |
Countdown 事件
方法 | 描述 | 类型 |
---|---|---|
change | 时间差变化事件 | Function |
finish | 倒计时结束事件 | Function |
Countdown 插槽
名称 | 描述 |
---|---|
prefix | 倒计时值前缀 |
suffix | 倒计时值后缀 |
title | 倒计时标题 |
Countdown 暴露
名称 | 描述 | 类型 |
---|---|---|
displayValue | 当前显示值 | object |