首页 > 其他分享 >vue+el-timeline动态表格时间线

vue+el-timeline动态表格时间线

时间:2023-09-08 12:58:28浏览次数:33  
标签:el vue 表格 timeline indexCode label dictList

原文链接:https://blog.csdn.net/Shids_/article/details/126645038

前言
当我们需要在页面中展示一系列时间相关的事件时,常常会考虑使用时间线来呈现。而在 vue 框架中,我们可以借助一些组件库来快速实现时间线的功能。其中, el-timeline 就是一款非常优秀的时间线组件,它可以帮助我们快速地实现动态表格时间线的效果。本文将介绍如何基于 el-timeline 组件来实现 vue 中的动态表格时间线。

实现效果:


实现思路:
其实实现这个小功能非常简单,首先,我们要在 el-timeline-item 标签循环最外层的 dataList 数组,数组的 length 等于几,我们就会有几段时间线;表格中我们需要操作的是将固有的表格数据格式(一个数组)稍加修改,变成两个数组,将 el-table 中 data 属性动态绑定上 dictList 数组(表格数据),再在 el-table-column 标签中循环 dictList 数组(表头数据),最后通过 prop 和 label 属性动态绑定匹配对应的值即可。

源码如下:
<template>
<div>
<el-dialog title="历史信息" :visible.sync="centerDialogVisible" width="50%">
<el-timeline>
<el-timeline-item placement="top" :timestamp="item.sj" v-for="(item, index) in dataList" :key="index">
<el-card>
<el-table :data="item.rows" border>
<el-table-column v-for="(item, index) in item.dictList" :prop="item.indexCode" :label="item.label" :key="index" align="center"></el-table-column>
</el-table>
</el-card>
</el-timeline-item>
</el-timeline>

</el-dialog>
</div>
</template>

<script>
export default {
data() {
return {
// 模拟数据
dataList: [
{
sj: "2022-09-01",
dictList: [
{
indexCode: "name",
label: "姓名",
},
{
indexCode: "sex",
label: "性别",
},
{
indexCode: "age",
label: "年龄",
},
],
rows: [
{
name: "小明",
sex: "女",
age: "18",
},
],
},
{
sj: "2022-08-01",
dictList: [
{
indexCode: "firmName",
label: "企业名称",
},
{
indexCode: "site",
label: "企业地址",
},
{
indexCode: "date",
label: "注册日期",
},
],
rows: [
{
firmName: "文化有限公司",
site: "北京",
date: "2018-01-25",
},
],
},
{
sj: "2022-07-01",
dictList: [
{
indexCode: "plate",
label: "车牌号",
},
{
indexCode: "fuel",
label: "燃料类型",
},
{
indexCode: "plateColor",
label: "车牌颜色",
},
],
rows: [
{
plate: "京R11111",
fuel: "柴油",
plateColor: "蓝色",
},
],
},
],
centerDialogVisible: true, //弹框显隐状态
};
},
};
</script>

<style scoped>
h3 {
margin: 10px 0px;
}
</style>

标签:el,vue,表格,timeline,indexCode,label,dictList
From: https://www.cnblogs.com/fswhq/p/17681648.html

相关文章

  • Firefox正在优化Vue.js,后续将提高运行效率
        据了解,日前Firefox浏览器正针对Vue.js进行优化,而早前FireFox浏览器在面向Vue3时遇到了一些性能问题。当前开发人员在Firefox118内部版本中进行了测试,而正式版本将于9月底发布,将“显著提升”Vue.js的运行效率ireiuposghj。据了解,开发人员目前正在更新Speedo......
  • Vue 判断开始时间不能大于结束时间
    原文链接:https://blog.csdn.net/lzfengquan/article/details/119993515<template><div><el-formref="form":model="form"label-width="80px"><el-form-itemlabel="活动时间"><el-col:......
  • Vue可输入的下拉框
    原文链接:https://blog.csdn.net/m0_72189030/article/details/130881295<template><el-selectv-model="value"placeholder="请选择"clearable:style="{width:'100%'}"filterableallow-create:fi......
  • 使用EasyExcel下载文件时,前端获取不到后端返回的文件名,无法下载到本地
    【问题描述】使用EasyExcel下载文件时,前端获取不到后端返回的文件名,无法下载到本地 【原因分析】实际上文件的流后端已经返回了,只是缺少了Content-Disposition属性返回,前端无法获取到文件名;privatestaticOutputStreamgetOutputStream(StringfileName,HttpServletRespon......
  • POI向Excel中写入数据及追加数据
    importorg.apache.poi.xssf.usermodel.XSSFCell;importorg.apache.poi.xssf.usermodel.XSSFRow;importorg.apache.poi.xssf.usermodel.XSSFSheet;importorg.apache.poi.xssf.usermodel.XSSFWorkbook;importjava.io.*;importjava.util.ArrayList;importjava.util......
  • Linux shell 环境变量 All In One
    Linuxshell环境变量AllInOne全局环境变量,systemwideenvironment系统级环境变量局部环境变量,localwideenvironment用户自定义环境变量shell的3种启动方式登录默认的交互式shell非登录的交互式shell运行脚本的非交互式shellshell的常见类型shba......
  • 配置Babel
    配置Babel参考资料https://mp.weixin.qq.com/s/UcLHGzZdPoS8B14X7RhDEA问题我们在使用各种打包工具,需要配置Babel的时候,相信大家一开始都是直接在网上复制粘贴一段配置过来,然后能跑通就万事大吉了吧?因此,我们有时会遇到打包部署后,手机运行出现白屏问题;或者是,打包后代码包过大,加......
  • Vue -el-table表格动态控制表头动态展示数据(控制每一列展示)
    前言最近在实际开发中我们遇到一个需求是用户自己控制键值来生成对应表格数据。换个思路就是我们还是正常查询数据,需要一个开关页面来动态改变表格展示每一列。我们需要一个开关页面,里面有多选,确定重置取消,确定时把选中数据传递给父组件,动态数据for循环最好是以封装成组件的形......
  • el-input 回车事件keydown刷新页面(白屏)
    因为触发了form表单的事件,禁用即可,@submit.prevent<el-form:model="form"[email protected]><el-form-itemlabel=""><el-inputv-model="form.code"placeholder=""......
  • vue2使用 AMap-Vue 高德地图(矩形、圆形、多边形)绘制电子围栏
     AMap-Vue 参考 安装使用|AMap-Vue(gitee.io)main.js引入importAmapVuefrom'@amap/amap-vue';Vue.use(AmapVue);AmapVue.config.key='您申请的key值';AmapVue.config.version='2.0';//默认2.0,这里可以不修改AmapVue.config.plugins=["A......