2019-01-09 20:38:09 +08:00
|
|
|
---
|
|
|
|
order: 2
|
|
|
|
title:
|
|
|
|
zh-CN: 在卡片中使用
|
|
|
|
en-US: In Card
|
|
|
|
---
|
|
|
|
|
|
|
|
## zh-CN
|
|
|
|
|
|
|
|
在卡片中展示统计数值。
|
|
|
|
|
|
|
|
## en-US
|
|
|
|
|
|
|
|
Display statistic data in Card.
|
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
```tsx
|
2022-05-21 22:14:15 +08:00
|
|
|
import { ArrowDownOutlined, ArrowUpOutlined } from '@ant-design/icons';
|
|
|
|
import { Card, Col, Row, Statistic } from 'antd';
|
2022-05-19 09:46:26 +08:00
|
|
|
import React from 'react';
|
2019-01-09 20:38:09 +08:00
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
const App: React.FC = () => (
|
2019-12-24 20:58:42 +08:00
|
|
|
<div className="site-statistic-demo-card">
|
2019-01-09 20:38:09 +08:00
|
|
|
<Row gutter={16}>
|
|
|
|
<Col span={12}>
|
|
|
|
<Card>
|
|
|
|
<Statistic
|
|
|
|
title="Active"
|
|
|
|
value={11.28}
|
|
|
|
precision={2}
|
|
|
|
valueStyle={{ color: '#3f8600' }}
|
2019-11-28 12:34:33 +08:00
|
|
|
prefix={<ArrowUpOutlined />}
|
2019-01-09 20:38:09 +08:00
|
|
|
suffix="%"
|
|
|
|
/>
|
|
|
|
</Card>
|
|
|
|
</Col>
|
|
|
|
<Col span={12}>
|
|
|
|
<Card>
|
|
|
|
<Statistic
|
|
|
|
title="Idle"
|
|
|
|
value={9.3}
|
|
|
|
precision={2}
|
|
|
|
valueStyle={{ color: '#cf1322' }}
|
2019-11-28 12:34:33 +08:00
|
|
|
prefix={<ArrowDownOutlined />}
|
2019-01-09 20:38:09 +08:00
|
|
|
suffix="%"
|
|
|
|
/>
|
|
|
|
</Card>
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2022-04-03 23:27:45 +08:00
|
|
|
</div>
|
2019-01-09 20:38:09 +08:00
|
|
|
);
|
2022-05-19 09:46:26 +08:00
|
|
|
|
|
|
|
export default App;
|
2019-01-09 20:38:09 +08:00
|
|
|
```
|
2019-12-24 20:58:42 +08:00
|
|
|
|
|
|
|
```css
|
|
|
|
.site-statistic-demo-card {
|
|
|
|
padding: 30px;
|
2021-01-30 19:39:02 +08:00
|
|
|
background: #ececec;
|
2019-12-24 20:58:42 +08:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
<style>
|
|
|
|
[data-theme="dark"] .site-statistic-demo-card {
|
|
|
|
background: #303030;
|
|
|
|
}
|
|
|
|
</style>
|