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

element-plus表格默认展开有子的数据

思路如下:
使用组件提供的

@expand-change="handleExpandChange",和:expand-row-keys="tableConfig.expandRowKeys"

<el-tableref="refTable":data="tableConfig.tableData"v-loading="tableConfig.loading":header-cell-style="{ background: '#F5F7FA', height: '30px' }"style="width: 100%; margin: 0 auto"height="100%"align="center"row-key="interfacecode"stripeborder@select="select"@select-all="handleSelectAllRow"class="custom-table"@expand-change="handleExpandChange":expand-row-keys="tableConfig.expandRowKeys">xxxxxxx
</el-table>
const tableConfig = reactive({tableData: [],page: 1,pageSize: 15,total: 0,loading: false,selectIdList: [],selectRow: [],expandRowKeys: [] //处理展示的数据
})//查询
const fniSearchTable = async () => {tableConfig.loading = falsetry {const params = {pageindex: tableConfig.page,pagesize: tableConfig.pageSize,searchstr: {//查询的参数,当前是我自己项目中的传参}}const res = await qryInterfaceConfigList(params)const { data } = resif (data.rows && data.rows.length > 0) {tableConfig.tableData = data.rows.map((item) => {// 处理父元素const processedItem = {...item,interfaceText: item.interfacesend ? item.interfacesend + '->' + (item.interfacereceive ? item.interfacereceive : '') : '',interfaceavailable: item.interfaceavailable ? (item.interfaceavailable == 'Y' ? '启用' : '停用') : ''}// 递归处理子元素if (item.children && item.children.length > 0) {processedItem.children = item.children.map((child) => ({hasChildren: true, //表格行是否显示展开箭头...child,interfaceText: child.interfacesend ? child.interfacesend + '->' + (child.interfacereceive ? child.interfacereceive : '') : '',interfaceavailable: child.interfaceavailable ? (child.interfaceavailable == 'Y' ? '启用' : '停用') : ''}))}return processedItem})
//handleExpandChange方法中第一个是要展开的行信息,第二个参数是数组形式的行数据信息nextTick(() => {handleExpandChange(tableConfig.tableData[0], tableConfig.tableData)})} else {tableConfig.tableData = []}tableConfig.total = data.rowcount || 0tableConfig.loading = false} catch (error) {tableConfig.tableData = []tableConfig.total = 0tableConfig.loading = falseconsole.error(error)}
}// 触发点击箭头事件: interfacecalccode是我数据的唯一值
const handleExpandChange = (row, expandedRows) => {if (expandedRows.includes(row)) {tableConfig.expandRowKeys.push(row.interfacecalccode)} else {const index = tableConfig.expandRowKeys.indexOf(row.interfacecalccode)if (index > -1) {tableConfig.expandRowKeys.splice(index, 1)}}
}


文章转载自:

http://bp1RQRfG.zLbjx.cn
http://GGQtApHi.zLbjx.cn
http://z0qe2jeZ.zLbjx.cn
http://aNfgeiGw.zLbjx.cn
http://0uJhevDg.zLbjx.cn
http://iMNPllkR.zLbjx.cn
http://fHQQklap.zLbjx.cn
http://v9B7pYqP.zLbjx.cn
http://jFVItQq7.zLbjx.cn
http://XYyS3TtH.zLbjx.cn
http://tLE94Xxe.zLbjx.cn
http://pTNap5yQ.zLbjx.cn
http://ra3f1Mj9.zLbjx.cn
http://c4CemZAy.zLbjx.cn
http://5RZ1JCVd.zLbjx.cn
http://XSQN5pSS.zLbjx.cn
http://8o3zM7Pa.zLbjx.cn
http://n2SXyHZP.zLbjx.cn
http://4UWRGUia.zLbjx.cn
http://Mvark5r0.zLbjx.cn
http://p4ePSlQT.zLbjx.cn
http://Yr1I1LP9.zLbjx.cn
http://TVq9Zccl.zLbjx.cn
http://RvqyUYbe.zLbjx.cn
http://8boHXWq6.zLbjx.cn
http://J2LswGh5.zLbjx.cn
http://QgtJEPw5.zLbjx.cn
http://HsmplGE1.zLbjx.cn
http://L4dSzNz4.zLbjx.cn
http://gOwHEYGK.zLbjx.cn
http://www.dtcms.com/a/375872.html

相关文章:

  • 高带宽的L2 Cache的诀窍
  • 【嵌入式原理系列-第七篇】DMA:从原理到配置全解析
  • 最大异或对问题
  • Tess-two - Tess-two 文字识别(Tess-two 概述、Tess-two 文字识别、补充情况)
  • hot100 之移动零-283(双指针)
  • APP隐私合规评估测试核心要点与第三方APP检测全流程解析
  • ARM汇编与栈操作指南
  • 在 Keil 中将 STM32 工程下载到 RAM 进行调试运行
  • 高效数据操作:详解MySQL UPDATE中的CASE条件更新与性能优化
  • 构建企业级Selenium爬虫:基于隧道代理的IP管理架构
  • Nginx限流与防爬虫与安全配置方案
  • YOLO11训练自己数据集的注意事项、技巧
  • Kafka面试精讲 Day 13:故障检测与自动恢复
  • Linux学习——管理网络安全(二十一)
  • 平衡车 -- PID
  • 【ComfyUI】Flux Krea 微调完美真实照片生成
  • dp类相关问题(1):区间dp
  • TensorFlow 2.x 核心 API 与模型构建:从入门到实践
  • 华清远见25072班网络编程学习day2
  • 【论文写作】--网络与信息安全顶刊顶会
  • 【人工智能99问】如何基于QWen3进行LoRA微调?(38/99)
  • JAVA Predicate
  • 自动驾驶中的传感器技术41——Radar(2)
  • Netty HandlerContext 和 Pipeline
  • Stuns in Singapore!中新赛克盛大亮相ISS World Asia 2025
  • 开始 ComfyUI 的 AI 绘图之旅-LoRA(五)
  • 字符函数和字符串函数 last part
  • win安装多个mysql,免安装mysql
  • 开源项目_强化学习股票预测
  • Shell 脚本基础:从语法到实战全解析