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>
相关推荐
SailingCoder1 小时前
【 从“打补丁“到“换思路“ 】一次企业级 AI Agent 的架构拐点
大数据·前端·人工智能·面试·架构·agent
~央千澈~1 小时前
抖音弹幕游戏开发之第12集:添加冷却时间机制·优雅草云桧·卓伊凡
java·服务器·前端
CappuccinoRose1 小时前
CSS 语法学习文档(十三)
前端·css·学习·postcss·模块化·预处理器
OpenTiny社区1 小时前
Angular Module→Standalone 架构进化解析
前端·架构·angular.js
哆啦A梦15882 小时前
Vue3魔法手册 作者 张天禹 06_监控
前端·vue.js·typescript
恋猫de小郭2 小时前
你知道不,你现在给 AI 用的 Agent Skills 可能毫无作用,甚至还拖后腿?
前端·人工智能·ai编程
用户600071819103 小时前
【翻译】用生成器实现可续充队列
前端
少云清3 小时前
【UI自动化测试】4_web自动化测试 _元素定位(重点)
前端·web前端自动化
若丶相见3 小时前
腾讯云完整部署方案:CODING + CI/CD + Docker + Nginx + K8s 扩展
前端·后端
比奇堡鱼贩4 小时前
python第五次作业
开发语言·前端·python