Statistic 统计数值
用于突出展示统计类数值。
基础用法
可围绕数值配置标题、前后缀、图标等;也可结合 vueuse useTransition
Daily active users
268,500
Ratio of men to women
138
/100
Total Transactions
0
Feedback number
562
vue
<template>
<u-row :gutter="16">
<u-col :xs="24" :sm="12" :md="6" class="text-center mb-4">
<u-statistic title="Daily active users" :value="268500" />
</u-col>
<u-col :xs="24" :sm="12" :md="6" class="text-center mb-4">
<u-statistic :value="138">
<template #title>
<div style="display: inline-flex; align-items: center">
Ratio of men to women
<u-icon style="margin-left: 4px" :size="12">
<Male />
</u-icon>
</div>
</template>
<template #suffix>/100</template>
</u-statistic>
</u-col>
<u-col :xs="24" :sm="12" :md="6" class="text-center mb-4">
<u-statistic title="Total Transactions" :value="outputValue" />
</u-col>
<u-col :xs="24" :sm="12" :md="6" class="text-center mb-4">
<u-statistic title="Feedback number" :value="562">
<template #suffix>
<u-icon style="vertical-align: -0.125em">
<ChatLineRound />
</u-icon>
</template>
</u-statistic>
</u-col>
</u-row>
</template>
<script lang="ts" setup>
import { ref } from 'vue'
import { useTransition } from '@vueuse/core'
import { ChatLineRound, Male } from '@uniboot/icons-vue'
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-06-01
vue
<template>
<u-row :gutter="16">
<u-col :xs="24" :sm="12" :md="8" class="text-center mb-4">
<u-countdown title="Start to grab" :value="value" />
</u-col>
<u-col :xs="24" :sm="12" :md="8" class="text-center mb-4">
<u-countdown
title="Remaining VIP time"
format="HH:mm:ss"
:value="value1"
/>
<u-button class="countdown-footer" type="primary" @click="reset">
Reset
</u-button>
</u-col>
<u-col :xs="24" :sm="12" :md="8" class="text-center mb-4">
<u-countdown format="DD [days] HH:mm:ss" :value="value2">
<template #title>
<div style="display: inline-flex; align-items: center">
<u-icon style="margin-right: 4px" :size="12">
<Calendar />
</u-icon>
Still to go until next month
</div>
</template>
</u-countdown>
<div class="countdown-footer">{{ value2.format('YYYY-MM-DD') }}</div>
</u-col>
</u-row>
</template>
<script lang="ts" setup>
import { ref } from 'vue'
import dayjs from 'dayjs'
import { Calendar } from '@uniboot/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>
隐藏源代码
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>
<u-row :gutter="16">
<u-col :xs="24" :sm="12" :md="8" class="mb-4">
<div class="statistic-card">
<u-statistic :value="98500">
<template #title>
<div style="display: inline-flex; align-items: center">
Daily active users
<u-tooltip
effect="dark"
content="Number of users who logged into the product in one day"
placement="top"
>
<u-icon style="margin-left: 4px" :size="12">
<Warning />
</u-icon>
</u-tooltip>
</div>
</template>
</u-statistic>
<div class="statistic-footer">
<div class="footer-item">
<span>than yesterday</span>
<span class="green">
24%
<u-icon>
<CaretTop />
</u-icon>
</span>
</div>
</div>
</div>
</u-col>
<u-col :xs="24" :sm="12" :md="8" class="mb-4">
<div class="statistic-card">
<u-statistic :value="693700">
<template #title>
<div style="display: inline-flex; align-items: center">
Monthly Active Users
<u-tooltip
effect="dark"
content="Number of users who logged into the product in one month"
placement="top"
>
<u-icon style="margin-left: 4px" :size="12">
<Warning />
</u-icon>
</u-tooltip>
</div>
</template>
</u-statistic>
<div class="statistic-footer">
<div class="footer-item">
<span>month on month</span>
<span class="red">
12%
<u-icon>
<CaretBottom />
</u-icon>
</span>
</div>
</div>
</div>
</u-col>
<u-col :xs="24" :sm="12" :md="8" class="mb-4">
<div class="statistic-card">
<u-statistic :value="72000" title="New transactions today">
<template #title>
<div style="display: inline-flex; align-items: center">
New transactions today
</div>
</template>
</u-statistic>
<div class="statistic-footer">
<div class="footer-item">
<span>than yesterday</span>
<span class="green">
16%
<u-icon>
<CaretTop />
</u-icon>
</span>
</div>
<div class="footer-item">
<u-icon :size="14">
<ArrowRight />
</u-icon>
</div>
</div>
</div>
</u-col>
</u-row>
</template>
<script lang="ts" setup>
import { ArrowRight, CaretBottom, CaretTop, Warning } from '@uniboot/icons-vue'
</script>
<style scoped>
:global(h2#card-usage ~ .example .example-showcase) {
background-color: var(--u-fill-color) !important;
}
.u-statistic {
--u-statistic-content-font-size: 28px;
}
.statistic-card {
height: 100%;
padding: 20px;
border-radius: 4px;
background-color: var(--u-bg-color-overlay);
}
.statistic-footer {
display: flex;
justify-content: space-between;
align-items: center;
flex-wrap: wrap;
font-size: 12px;
color: var(--u-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(--u-color-success);
}
.red {
color: var(--u-color-error);
}
</style>
隐藏源代码
统计数值 API
统计数值 属性
| 名称 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| value | 数值内容 | number | 0 |
| decimal-separator | 小数点符号 | string | . |
| formatter | 自定义数值格式化函数 | Function | — |
| group-separator | 千分位分隔符 | string | , |
| precision | 数值精度 | number | 0 |
| prefix | 前缀 | string | — |
| suffix | 后缀 | string | — |
| title | 标题 | string | — |
| value-style | 数值样式 | string / object | — |
统计数值 插槽
| 名称 | 说明 |
|---|---|
| prefix | 数值前缀 |
| suffix | 数值后缀 |
| title | 标题 |
统计数值 方法
| 名称 | 说明 | 类型 |
|---|---|---|
| displayValue | 当前展示字符串/数值 | object |
倒计时 API
倒计时 属性
| 名称 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| value | 目标时间(时间戳或 Dayjs) | number / Dayjs | — |
| format | 展示格式 | string | HH:mm:ss |
| prefix | 前缀 | string | — |
| suffix | 后缀 | string | — |
| title | 标题 | string | — |
| value-style | 数值样式 | string / object | — |
倒计时 事件
| 事件名 | 说明 | 类型 |
|---|---|---|
| change | 剩余时间变化 | Function |
| finish | 倒计时结束 | Function |
倒计时 插槽
| 名称 | 说明 |
|---|---|
| prefix | 倒计时数值前缀 |
| suffix | 倒计时数值后缀 |
| title | 标题 |
倒计时 方法
| 名称 | 说明 | 类型 |
|---|---|---|
| displayValue | 当前展示字符串 | object |