Timeline 时间线

可视化地呈现时间流信息。

基础用法

Timeline 可拆分成多个按照时间戳排列的活动, 时间戳是其区分于其他控件的重要特征, 使用时注意与 Steps 步骤条等区分。

Timeline 时间线 - 图1

  1. <template>
  2. <el-timeline>
  3. <el-timeline-item
  4. v-for="(activity, index) in activities"
  5. :key="index"
  6. :timestamp="activity.timestamp"
  7. >
  8. {{ activity.content }}
  9. </el-timeline-item>
  10. </el-timeline>
  11. </template>
  12. <script lang="ts" setup>
  13. const activities = [
  14. {
  15. content: 'Event start',
  16. timestamp: '2018-04-15',
  17. },
  18. {
  19. content: 'Approved',
  20. timestamp: '2018-04-13',
  21. },
  22. {
  23. content: 'Success',
  24. timestamp: '2018-04-11',
  25. },
  26. ]
  27. </script>

⾃定义节点样式

可根据实际场景⾃定义节点尺⼨、颜⾊,或直接使⽤图标。

Timeline 时间线 - 图2

  1. <template>
  2. <el-timeline>
  3. <el-timeline-item
  4. v-for="(activity, index) in activities"
  5. :key="index"
  6. :icon="activity.icon"
  7. :type="activity.type"
  8. :color="activity.color"
  9. :size="activity.size"
  10. :hollow="activity.hollow"
  11. :timestamp="activity.timestamp"
  12. >
  13. {{ activity.content }}
  14. </el-timeline-item>
  15. </el-timeline>
  16. </template>
  17. <script lang="ts" setup>
  18. import { MoreFilled } from '@element-plus/icons-vue'
  19. const activities = [
  20. {
  21. content: 'Custom icon',
  22. timestamp: '2018-04-12 20:46',
  23. size: 'large',
  24. type: 'primary',
  25. icon: MoreFilled,
  26. },
  27. {
  28. content: 'Custom color',
  29. timestamp: '2018-04-03 20:46',
  30. color: '#0bbd87',
  31. },
  32. {
  33. content: 'Custom size',
  34. timestamp: '2018-04-03 20:46',
  35. size: 'large',
  36. },
  37. {
  38. content: 'Custom hollow',
  39. timestamp: '2018-04-03 20:46',
  40. type: 'primary',
  41. hollow: true,
  42. },
  43. {
  44. content: 'Default node',
  45. timestamp: '2018-04-03 20:46',
  46. },
  47. ]
  48. </script>

⾃定义时间戳

当内容在垂直⽅向上过⾼时,可将时间戳置于内容之上。

Timeline 时间线 - 图3

  1. <template>
  2. <el-timeline>
  3. <el-timeline-item timestamp="2018/4/12" placement="top">
  4. <el-card>
  5. <h4>Update Github template</h4>
  6. <p>Tom committed 2018/4/12 20:46</p>
  7. </el-card>
  8. </el-timeline-item>
  9. <el-timeline-item timestamp="2018/4/3" placement="top">
  10. <el-card>
  11. <h4>Update Github template</h4>
  12. <p>Tom committed 2018/4/3 20:46</p>
  13. </el-card>
  14. </el-timeline-item>
  15. <el-timeline-item timestamp="2018/4/2" placement="top">
  16. <el-card>
  17. <h4>Update Github template</h4>
  18. <p>Tom committed 2018/4/2 20:46</p>
  19. </el-card>
  20. </el-timeline-item>
  21. </el-timeline>
  22. </template>

垂直居中

垂直居中样式的 Timeline-Item

Timeline 时间线 - 图4

  1. <template>
  2. <el-timeline>
  3. <el-timeline-item center timestamp="2018/4/12" placement="top">
  4. <el-card>
  5. <h4>Update Github template</h4>
  6. <p>Tom committed 2018/4/12 20:46</p>
  7. </el-card>
  8. </el-timeline-item>
  9. <el-timeline-item timestamp="2018/4/3" placement="top">
  10. <el-card>
  11. <h4>Update Github template</h4>
  12. <p>Tom committed 2018/4/3 20:46</p>
  13. </el-card>
  14. </el-timeline-item>
  15. <el-timeline-item center timestamp="2018/4/2" placement="top">
  16. Event start
  17. </el-timeline-item>
  18. <el-timeline-item timestamp="2018/4/2" placement="top">
  19. Event end
  20. </el-timeline-item>
  21. </el-timeline>
  22. </template>

Timeline 插槽

插槽名说明子标签
时间戳Timeline-Item

Timeline-Item 属性

属性说明类型可选值默认值
timestamp时间戳string
hide-timestamp是否隐藏时间戳booleanfalse
center是否垂直居中booleanfalse
placement时间戳位置stringtop / bottombottom
type节点类型stringprimary / success / warning / danger / info
color节点颜色stringhsl / hsv / hex / rgb
size节点尺寸stringnormal / largenormal
icon自定义图标string | Component
hollow是否空心点booleanfalse

Timeline-Item 插槽

插槽名说明
Timeline-Item 的内容
dot自定义节点

源代码

组件 Timeline 时间线 - 图5 文档 Timeline 时间线 - 图6

贡献者

Timeline 时间线 - 图7 三咲智子

Timeline 时间线 - 图8 jeremywu

Timeline 时间线 - 图9 云游君

Timeline 时间线 - 图10 zz

Timeline 时间线 - 图11 류한경

Timeline 时间线 - 图12 Aex

Timeline 时间线 - 图13 Anas Boudih

Timeline 时间线 - 图14 Delyan Haralanov

Timeline 时间线 - 图15 Herrington Darkholme

Timeline 时间线 - 图16 BeADre

Timeline 时间线 - 图17 kooriookami

Timeline 时间线 - 图18 on the field of hope

Timeline 时间线 - 图19 Hades-li

Timeline 时间线 - 图20 啝裳

Timeline 时间线 - 图21 C.Y.Kun

Timeline 时间线 - 图22 qiang