2016-03-31 14:17:09 +08:00
|
|
|
|
---
|
|
|
|
|
category: Components
|
2022-11-09 12:28:04 +08:00
|
|
|
|
group: 数据展示
|
2016-09-21 11:28:38 +08:00
|
|
|
|
title: Timeline
|
2024-03-22 14:22:42 +08:00
|
|
|
|
subtitle: 时间轴
|
|
|
|
|
description: 垂直展示的时间流信息。
|
2022-11-30 20:14:41 +08:00
|
|
|
|
cover: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*FkTySqNt3sYAAAAAAAAAAAAADrJ8AQ/original
|
2023-02-09 22:17:31 +08:00
|
|
|
|
coverDark: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*yIl9S4hAIBcAAAAAAAAAAAAADrJ8AQ/original
|
2022-11-09 12:28:04 +08:00
|
|
|
|
demo:
|
|
|
|
|
cols: 2
|
2016-03-31 14:17:09 +08:00
|
|
|
|
---
|
2015-09-01 11:47:12 +08:00
|
|
|
|
|
|
|
|
|
## 何时使用
|
|
|
|
|
|
2017-12-27 17:54:12 +08:00
|
|
|
|
- 当有一系列信息需按时间排列时,可正序和倒序。
|
|
|
|
|
- 需要有一条时间轴进行视觉上的串联时。
|
2015-09-01 21:15:31 +08:00
|
|
|
|
|
2024-01-05 10:12:22 +08:00
|
|
|
|
<!-- prettier-ignore -->
|
2024-04-07 17:02:59 +08:00
|
|
|
|
:::info{title="升级提示"}
|
|
|
|
|
5.2.0 版本之后,我们提供了更简单的用法 `<Timeline items={[...]} />` 以获得更好的性能,使您能在应用中编写更简单的代码。
|
2024-01-05 10:12:22 +08:00
|
|
|
|
与此同时,我们弃用了旧的用法,并且将在下一个 major 版本中删除它。
|
|
|
|
|
:::
|
2023-02-08 10:27:07 +08:00
|
|
|
|
|
|
|
|
|
```jsx
|
|
|
|
|
// >=5.2.0 可用,推荐的写法 ✅
|
|
|
|
|
const items = [{ children: 'sample', label: 'sample' }];
|
|
|
|
|
return <Timeline items={items} />;
|
|
|
|
|
|
|
|
|
|
// <5.2.0 可用,>=5.2.0 时不推荐 🙅🏻♀️
|
|
|
|
|
return (
|
|
|
|
|
<Timeline onChange={onChange}>
|
|
|
|
|
<Timeline.Item>Sample</Timeline.Item>
|
|
|
|
|
</Timeline>
|
|
|
|
|
);
|
|
|
|
|
```
|
|
|
|
|
|
2022-11-09 12:28:04 +08:00
|
|
|
|
## 代码演示
|
|
|
|
|
|
2022-11-17 17:31:26 +08:00
|
|
|
|
<!-- prettier-ignore -->
|
2022-11-09 12:28:04 +08:00
|
|
|
|
<code src="./demo/basic.tsx">基本用法</code>
|
|
|
|
|
<code src="./demo/color.tsx">圆圈颜色</code>
|
|
|
|
|
<code src="./demo/pending.tsx">最后一个及排序</code>
|
|
|
|
|
<code src="./demo/alternate.tsx">交替展现</code>
|
|
|
|
|
<code src="./demo/custom.tsx">自定义时间轴点</code>
|
|
|
|
|
<code src="./demo/right.tsx">右侧时间轴点</code>
|
|
|
|
|
<code src="./demo/label.tsx">标签</code>
|
2022-12-06 23:14:30 +08:00
|
|
|
|
<code src="./demo/wireframe.tsx" debug>线框风格</code>
|
2023-05-22 09:36:14 +08:00
|
|
|
|
<code src="./demo/component-token.tsx" debug>组件 Token</code>
|
2022-11-09 12:28:04 +08:00
|
|
|
|
|
2023-02-07 16:16:48 +08:00
|
|
|
|
## API
|
|
|
|
|
|
2023-08-08 18:27:48 +08:00
|
|
|
|
通用属性参考:[通用属性](/docs/react/common-props)
|
|
|
|
|
|
2015-09-07 15:13:59 +08:00
|
|
|
|
### Timeline
|
|
|
|
|
|
2024-11-14 18:35:57 +08:00
|
|
|
|
| 参数 | 说明 | 类型 | 默认值 | 版本 |
|
|
|
|
|
| --- | --- | --- | --- | --- |
|
|
|
|
|
| mode | 通过设置 `mode` 可以改变时间轴和内容的相对位置 | `left` \| `alternate` \| `right` | - | |
|
|
|
|
|
| pending | 指定最后一个幽灵节点是否存在或内容 | ReactNode | false | |
|
|
|
|
|
| pendingDot | 当最后一个幽灵节点存在時,指定其时间图点 | ReactNode | <LoadingOutlined /> | |
|
|
|
|
|
| reverse | 节点排序 | boolean | false | |
|
|
|
|
|
| items | 选项配置 | [Items](#Items)[] | - | 5.2.0 |
|
2015-09-07 15:13:59 +08:00
|
|
|
|
|
2023-02-07 16:16:48 +08:00
|
|
|
|
### Items
|
2015-09-01 21:15:31 +08:00
|
|
|
|
|
|
|
|
|
时间轴的每一个节点。
|
|
|
|
|
|
2020-07-02 11:56:48 +08:00
|
|
|
|
| 参数 | 说明 | 类型 | 默认值 |
|
|
|
|
|
| --- | --- | --- | --- |
|
2022-03-13 00:30:51 +08:00
|
|
|
|
| color | 指定圆圈颜色 `blue`、`red`、`green`、`gray`,或自定义的色值 | string | `blue` |
|
2020-10-09 10:08:52 +08:00
|
|
|
|
| dot | 自定义时间轴点 | ReactNode | - |
|
2020-07-02 11:56:48 +08:00
|
|
|
|
| label | 设置标签 | ReactNode | - |
|
2023-02-07 16:16:48 +08:00
|
|
|
|
| children | 设置内容 | ReactNode | - |
|
2020-10-21 10:33:43 +08:00
|
|
|
|
| position | 自定义节点位置 | `left` \| `right` | - |
|
2023-04-11 10:25:24 +08:00
|
|
|
|
|
2023-08-30 23:02:35 +08:00
|
|
|
|
## 主题变量(Design Token)
|
2023-04-11 10:25:24 +08:00
|
|
|
|
|
|
|
|
|
<ComponentTokenTable component="Timeline"></ComponentTokenTable>
|