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

Vue3 动态列 <el-table-column> 实现 formatter 的两种方法

文章目录

    • 动态列实现
    • 动态列实现formatter
      • `第一种`
      • `第二种方法`

动态列实现

参考此篇文章 Vue3 动态列实现

动态列实现formatter

第一种

以此为例:传递该行的wxUserInfo字段(对象)中的nickName

  • 假设该行

{prop: "wxUserInfo", label: "用户昵称", minWidth: "110", align: "center", tooltip: true, resizable: true,},

<el-table-columnv-for="item in showList":label="item.label":key="item.prop":fixed="item.fixed":align="item.align":prop="item.prop":min-width="item.minWidth":width="item.width":show-overflow-tooltip="item.tooltip":resizable="item.resizable"><template v-slot="scope" v-if="item.prop == 'wxUserInfo'">{{ formatWxUserInfo(scope.row) }}</template></el-table-column>
const formatWxUserInfo = (row) => {return row.wxUserInfo.nickName;
}

第二种方法

个人比较喜欢第二种,简单的东西就不要浪费时间。

      <el-table-columnv-for="item in showList":label="item.label":key="item.prop":fixed="item.fixed":align="item.align":prop="item.prop":min-width="item.minWidth":width="item.width":show-overflow-tooltip="item.tooltip":resizable="item.resizable"><template v-slot="scope" v-if="item.prop == 'wxUserInfo'">{{ scope.row.wxUserInfo.nickName }}</template></el-table-column>
http://www.lryc.cn/news/121134.html

相关文章:

  • 室温超导是什么?有哪些应用场景?
  • Windows+VMware+Ubuntu+Anaconda+VMware Tools
  • Xray配置文件详解
  • flink优化
  • docker: ERROR: Couldn‘t connect to Docker daemon at http+docker://localhost
  • 大模型在金融医疗、生命系统和物理仿真领域的创新应用探索
  • tensorflow / tensorflow-gpu cuda cudNN tensorRT 安装,启用显卡加速
  • 计算机视觉中的Transformer
  • UVA-1601 万圣节后的早晨 题解答案代码 算法竞赛入门经典第二版
  • nacos 403错误
  • Python遥感图像处理应用篇(三十四):GDAL+Scikit-image+GLCM计算遥感图像纹理特征
  • solr迁移到另一个solr中(docker单机)
  • 谁能讲清楚Spark之Spark系统架构
  • 力扣:59. 螺旋矩阵 II(Python3)
  • 【electron】electron项目创建的方式:
  • Vim学习(一)——基本命令与三种模式
  • unity新输入系统的简单使用(New InputSystem)
  • Redis——特性介绍与应用场景
  • 网络:路由
  • 利用三维内容编辑器制作VR交互课件,简单好用易上手
  • 中国首款量子计算机操作系统本源司南 PilotOS正式上线
  • 基层社会治理平台建设方案[113页PPT]
  • 认识vite
  • 华为运动健康,十年创新天地宽
  • 深度学习(37)—— 图神经网络GNN(2)
  • Unity游戏源码分享-乐节奏休闲游戏源码 guitar hero 支持mobile
  • VS Code配置Prettier格式化Apex
  • Spring-Cloud-Loadblancer详细分析_4
  • openocd调试esp32(通过FT232H)
  • Nokia5110使用方法及实例编写51单片机