elment表格组件a-table属性formatter

table中列属性formatter,格式化表格数据->处理表格中显示的内容(像根据状态数值去显示当前状态对应的中文,或者处理一些是与否相间等)

实现代码
bash 复制代码
<template>
	<el-table-column 
      		v-for="(item,index) in columns" 
      		:prop="item.prop" 
      		:label="item.label" 
      		:width="item.width || ''" 
     		:formatter="item.formatter">
      </el-table-column>
</template>

<script setup>
const columns = ref([
  {
    label: '项目名称',
    prop: 'projectName' 
  },
  {
    label: '状态',
    prop: 'isEnable',
    formatter: (row) => {
      let curStatus = '';
      projectsData.findIndex(item => {
        if(item.value == row.isEnable) curStatus = item.label;
      })
      return curStatus
    }
  },
])
</script>
相关推荐
独立开发之道12 分钟前
【three.js教程】Three.js 材质详解:从“不反光“到“物理级真实“怎么选
开发语言·javascript·材质
ITmaster073114 分钟前
从零到一!前端搭建本地轻量化 RAG 问答系统
前端
夏炳辉.37 分钟前
Flex布局中 flex: 1 的完整解析与实战指南
前端·css·css3
CIO_Alliance1 小时前
AI提示系列(2)| Few-shot与ReAct有何不同? 大模型工具调用的底层逻辑详解
前端·人工智能·深度学习·神经网络·react.js·前端框架·ai+ipaas
一条破秋裤1 小时前
C-数据类型
c语言·开发语言·chrome
waillyer1 小时前
企业知识库智能问答 Agent(React + Nest)
javascript·redis·agent
cindershade1 小时前
别只收三个数字:前端 RUM 如何建立可解释的体验数据链
前端
前端 贾公子2 小时前
第09章:上下文与记忆 (4)
java·服务器·前端
Coodor2 小时前
使用web也可以写NFC微信小程序拉取
前端·微信小程序·小程序·nfc拉起小程序