mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-03 04:30:06 +08:00
6776bb8916
* docs: update demo * chore: add script * test: fix demo test * docs: convert demos * chore: move script * test: remove react-dom import * chore: update deps * docs: update riddle js * test: fix image test * docs: fix riddle demo
49 lines
1002 B
Markdown
49 lines
1002 B
Markdown
---
|
|
order: 3
|
|
title:
|
|
zh-CN: 倒计时
|
|
en-US: Countdown
|
|
---
|
|
|
|
## zh-CN
|
|
|
|
倒计时组件。
|
|
|
|
## en-US
|
|
|
|
Countdown component.
|
|
|
|
```jsx
|
|
import { Statistic, Row, Col } from 'antd';
|
|
|
|
const { Countdown } = Statistic;
|
|
const deadline = Date.now() + 1000 * 60 * 60 * 24 * 2 + 1000 * 30; // Moment is also OK
|
|
|
|
function onFinish() {
|
|
console.log('finished!');
|
|
}
|
|
|
|
function onChange(val) {
|
|
if (4.95 * 1000 < val && val < 5 * 1000) {
|
|
console.log('changed!');
|
|
}
|
|
}
|
|
|
|
export default () => (
|
|
<Row gutter={16}>
|
|
<Col span={12}>
|
|
<Countdown title="Countdown" value={deadline} onFinish={onFinish} />
|
|
</Col>
|
|
<Col span={12}>
|
|
<Countdown title="Million Seconds" value={deadline} format="HH:mm:ss:SSS" />
|
|
</Col>
|
|
<Col span={24} style={{ marginTop: 32 }}>
|
|
<Countdown title="Day Level" value={deadline} format="D 天 H 时 m 分 s 秒" />
|
|
</Col>
|
|
<Col span={12}>
|
|
<Countdown title="Countdown" value={Date.now() + 10 * 1000} onChange={onChange} />
|
|
</Col>
|
|
</Row>
|
|
);
|
|
```
|