当前位置: 首页 > news >正文

vue3 element-plus el-table 多层级表头动态渲染。

效果图:
在这里插入图片描述

html:

<el-table :data="arrlist" border style="width: 100%"><template v-for="(i, index) in currentFieldData" :key="index"><el-table-column :label="i.label" :header-D="i.headerAlign"><el-table-columnv-for="(k, k_index) in i.rows":key="k_index":label="k.label":prop="k.prop":header-align="k.align"></el-table-column><el-table-columnv-for="(y, y_index) in i.indexCustomIndex":key="y_index":label="y.label":prop="i.prop":header-align="y.align"><el-table-columnv-for="(x, x_index) in y.indexClassifyList":key="x_index":label="x.label":prop="x.prop":header-align="x.align"><template #default="scope"><span>  {{scope.row.custonindexlist[y_index].indexClassifyList[x_index].indexClassify}} </span></template></el-table-column></el-table-column></el-table-column></template></el-table>

js

<script setup lang="ts">
import { ElTable, ElTableColumn } from "element-plus";
// 字典:表头与list数组比对后,返回新的组装后的数组,再显示
//表头数据要动态渲染
//data 后台返回数据结构,如果不是自己想要的,就手动修改为自己需要的结构,在渲染列表const currentFieldData = [{label: "产品",prop: "产品",headerAlign: "center",rows: [{label: "111",prop: "danwei1",align: "center"},{label: "222",prop: "danwei2",align: "center"}],indexCustomIndex: [{label: "成立以来",prop: "from_fund_begin",align: "center",indexClassifyList: [{label: "1-1",prop: "index_classify_1",align: "center"},{label: "1-2",prop: "index_classify_2",align: "center"},{label: "1-3",prop: "index_classify_3",align: "center"}]},{label: "今年以来",prop: "from_this_year",align: "center",indexClassifyList: [{label: "2-1",prop: "index_classify_4",align: "center"},{label: "2-2",prop: "index_classify_5",align: "center"},{label: "2-3",prop: "index_classify_6",align: "center"}]}]},{label: "产品300",prop: "产品300",headerAlign: "center",rows: [{label: "指数",prop: "zhishu",align: "center"}],indexCustomIndex: [{label: "成立以来",prop: "from_fund_begin",align: "center",indexClassifyList: [{label: "2-1-1",prop: "index_classify_7",align: "center"},{label: "2-1-2",prop: "index_classify_8",align: "center"},{label: "2-1-3",prop: "index_classify_9",align: "center"}]},{label: "今年以来",prop: "from_this_year",align: "center",indexClassifyList: [{label: "2-2-1",prop: "index_classify_10",align: "center"},{label: "2-2-2",prop: "index_classify_11",align: "center"},{label: "2-2-3",prop: "index_classify_12",align: "center"}]}]}
];
const arrlist = [{danweijingzhi:'1.02',leijijingzhi:'2.0782',zhishu:'3.01',baseIndexList: [{baseIndexUpDownPercent: -0.1951,closePrice: 3341.953,indexCustomIndex: [{dateRange: "from_fund_begin",indexClassifyList: [{indexClassify: "index_classify_profit",indexDetailist: [{ indexType: "total_profit", indexValue: "3.0215" }]},{indexClassify: "index_classify_risk",indexDetailist: [{ indexType: "total_profit", indexValue: "3.0215" }]},{indexClassify: "index_classify_total",indexDetailist: [{ indexType: "total_profit", indexValue: "3.0215" }]}]},{dateRange: "from_this_year",indexClassifyList: [{indexClassify: "index_classify_profit",indexDetailist: [{ indexType: "total_profit", indexValue: "3.0215" }]},{indexClassify: "index_classify_risk",indexDetailist: [{ indexType: "total_profit", indexValue: "3.0215" }]},{indexClassify: "index_classify_total",indexDetailist: [{ indexType: "total_profit", indexValue: "3.0215" }]}]}],indexName: "000300"}],// 产品下的二层数据custonindexlist: [{dateRange: "from_fund_begin",indexClassifyList: [{indexClassify: "index_classify_profit",indexDetailist: [{ indexType: "total_profit", indexValue: "3.0215" }]},{indexClassify: "index_classify_risk",indexDetailist: [{ indexType: "total_profit", indexValue: "3.0215" }]},{indexClassify: "index_classify_total",indexDetailist: [{ indexType: "total_profit", indexValue: "3.0215" }]}]},{dateRange: "from_this_year",indexClassifyList: [{indexClassify: "index_classify_profit",indexDetailist: [{ indexType: "total_profit", indexValue: "3.0215" }]},{indexClassify: "index_classify_risk",indexDetailist: [{ indexType: "total_profit", indexValue: "3.0215" }]},{indexClassify: "index_classify_total",indexDetailist: [{ indexType: "total_profit", indexValue: "3.0215" }]}]}]}
];

http://www.mrgr.cn/news/14281.html

相关文章:

  • Android 12系统源码_输入系统(二)InputManagerService服务
  • C++领进门(第三讲)
  • Kubernetes与Docker的关系讲解
  • Quartz定时任务框架——若依
  • 基于vue框架的博物馆预约网站的设计与实现8k352(程序+源码+数据库+调试部署+开发环境)系统界面在最后面。
  • 大模型企业应用落地系列五》基于大模型的对话式推荐系统》大模型管理层
  • 【SpringCloud Alibaba】(八)学习 Sentinel 核心技术与配置规则(下)
  • 什么是池化层
  • HTML基础结构
  • 谷歌发布 3 款 Gemini 新模型;字节开源 FLUX Dev Hyper SD Lora,8 步生图丨 RTE 开发者日报
  • 图神经网络实战(19)——异构图神经网络
  • IOS 13 网络请求和Moya框架
  • SDI技术在专业视频应用中的角色与特性
  • 微前端集成优化:让所有子应用体积更小,加载更快!
  • 【Cadence24】如何给PCB板露铜处理
  • unity 自定义功能快捷键
  • MySQL 查询优化详解
  • Python 编程 之 tkinter : 导航栏与局部页面切换
  • 25届应届网安面试,默认页面信息泄露
  • docker快速安装node