Timeline 时间线

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

基础用法

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

Timeline 时间线 - 图1

  1. <divclass="block">
  2. <divclass="radio">
  3. 排序:
  4. <el-radio-groupv-model="reverse">
  5. <el-radio :label="true">倒序</el-radio>
  6. <el-radio :label="false">正序</el-radio>
  7. </el-radio-group>
  8. </div>
  9. <el-timeline :reverse="reverse">
  10. <el-timeline-item
  11. v-for="(activity, index) in activities"
  12. :key="index"
  13. :timestamp="activity.timestamp">
  14. {{activity.content}}
  15. </el-timeline-item>
  16. </el-timeline>
  17. </div>
  18. <script>
  19. exportdefault{
  20. data(){
  21. return{
  22. reverse:true,
  23. activities:[{
  24. content:'活动按期开始',
  25. timestamp:'2018-04-15'
  26. },{
  27. content:'通过审核',
  28. timestamp:'2018-04-13'
  29. },{
  30. content:'创建成功',
  31. timestamp:'2018-04-11'
  32. }]
  33. };
  34. }
  35. };
  36. </script>

⾃定义节点样式

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

Timeline 时间线 - 图2

<div class="block">
  <el-timeline>
    <el-timeline-item
      v-for="(activity, index) in activities"
      :key="index"
      :icon="activity.icon"
      :type="activity.type"
      :color="activity.color"
      :size="activity.size"
      :timestamp="activity.timestamp">
      {{activity.content}}
    </el-timeline-item>
  </el-timeline>
</div>

<script>
  export default {
    data() {
      return {
        activities: [{
          content: '支持使用图标',
          timestamp: '2018-04-12 20:46',
          size: 'large',
          type: 'primary',
          icon: 'el-icon-more'
        }, {
          content: '支持自定义颜色',
          timestamp: '2018-04-03 20:46',
          color: '#0bbd87'
        }, {
          content: '支持自定义尺寸',
          timestamp: '2018-04-03 20:46',
          size: 'large'
        }, {
          content: '默认样式的节点',
          timestamp: '2018-04-03 20:46'
        }]
      };
    }
  };
</script>

⾃定义时间戳

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

Timeline 时间线 - 图3

<div class="block">
  <el-timeline>
    <el-timeline-item timestamp="2018/4/12" placement="top">
      <el-card>
        <h4>更新 Github 模板</h4>
        <p>王小虎 提交于 2018/4/12 20:46</p>
      </el-card>
    </el-timeline-item>
    <el-timeline-item timestamp="2018/4/3" placement="top">
      <el-card>
        <h4>更新 Github 模板</h4>
        <p>王小虎 提交于 2018/4/3 20:46</p>
      </el-card>
    </el-timeline-item>
    <el-timeline-item timestamp="2018/4/2" placement="top">
      <el-card>
        <h4>更新 Github 模板</h4>
        <p>王小虎 提交于 2018/4/2 20:46</p>
      </el-card>
    </el-timeline-item>
  </el-timeline>
</div>

Timeline Attributes

参数说明类型可选值默认值
reverse指定节点排序方向,默认为正序booleanfalse

Timeline-item Attributes

参数说明类型可选值默认值
timestamp时间戳string-
hide-timestamp是否隐藏时间戳booleanfalse
placement时间戳位置stringtop / bottombottom
type节点类型stringprimary / success / warning / danger / info-
color节点颜色stringhsl / hsv / hex / rgb-
size节点尺寸stringnormal / largenormal
icon节点图标string-

Timeline-Item Slot

name说明
Timeline-Item 的内容
dot自定义节点