统计
显示统计数据。
基本用法
为了突出显示一个或一组数字,例如统计值、金额、排名等,可以在数字和标题前后添加图标、单位等元素。并使用 vueuse
Daily active users
268,500
Ratio of men to women
138
/100
Total Transactions
0
Feedback number
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 from '~icons/ep/chat-line-round'
import Male from '~icons/ep/male'
const source = ref(0)
const outputValue = useTransition(source, {
duration: 1500,
})
source.value = 172000
</script>
隐藏来源
倒计时
倒计时组件,支持添加其他组件控制倒计时。
Start to grab
00:00:00
Remaining VIP time
00:00:00
Still to go until next month
00 days 00:00:00
2026-05-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 '~icons/ep/calendar'
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>
隐藏来源
TIP
在格式化时建议在天数范围内
卡的使用
卡使用情况显示,可自由组合
Daily active users
98,500
than yesterday 24%
Monthly Active Users
693,700
month on month 12%
New transactions today
72,000
than yesterday 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 from '~icons/ep/arrow-right'
import CaretBottom from '~icons/ep/caret-bottom'
import CaretTop from '~icons/ep/caret-top'
import Warning from '~icons/ep/warning'
</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>
隐藏来源
统计API
统计属性
| 属性 | 描述 | 类型 | 默认 |
|---|---|---|---|
| 价值 | 数值内容 | 数字 | 0 |
| 小数点分隔符 | 设置小数点 | 字符串 | 。 |
| 格式化程序 | 自定义数字演示 | 功能 | — |
| 组分隔符 | 设置第千个标识符 | 字符串 | , |
| 精度 | 数值精度 | 数字 | 0 |
| 前缀 | 设置号码的前缀 | 字符串 | — |
| 后缀 | 设置数字的后缀 | 字符串 | — |
| 标题 | 数字标题 | 字符串 | — |
| 价值风格 | 数值样式 | 字符串 / 对象 | — |
统计槽位
|名称 |描述 | | ------ | ------------------------ | | |前缀 |数字前缀 | |后缀|数值后缀 | |标题 |数字标题 |
统计数据暴露
| 名称 | 描述 | 类型 |
|---|---|---|
| 显示值 | 当前显示值 | 对象 |
倒计时API
倒计时属性
| 属性 | 描述 | 类型 | 默认 |
|---|---|---|---|
| 价值 | 目标时间 | 数字 / Dayjs | — |
| 格式 | 格式化倒计时显示 | 字符串 | 时:分:秒 |
| 前缀 | 设置倒计时的前缀 | 字符串 | — |
| 后缀 | 设置倒计时的后缀 | 字符串 | — |
| 标题 | 倒计时标题 | 字符串 | — |
| 价值风格 | 样式倒计时值 | 字符串 / 对象 | — |
倒计时活动
| 名称 | 描述 | 类型 |
|---|---|---|
| 改变 | 时差变更事件 | 功能 |
| 完成 | 倒计时结束活动 | 功能 |
倒计时老虎机
| 名称 | 描述 |
|---|---|
| 前缀 | 倒计时值前缀 |
| 后缀 | 倒计时值后缀 |
| 标题 | 倒计时标题 |
倒计时曝光
| 名称 | 描述 | 类型 |
|---|---|---|
| 显示值 | 当前显示值 | 对象 |