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>
相关推荐
小二·1 天前
Vue 3 组件通信全方案详解:Props/Emit、provide/inject、事件总线替代与组合式函数封装
前端·javascript·vue.js
研☆香1 天前
html框架页面介绍及制作
前端·html
be or not to be1 天前
CSS 定位机制与图标字体
前端·css
DevUI团队1 天前
🔥Angular高效开发秘籍:掌握这些新特性,项目交付速度翻倍
前端·typescript·angular.js
Moment1 天前
如何在前端编辑器中实现像 Ctrl + Z 一样的撤销和重做
前端·javascript·面试
宠..1 天前
优化文件结构
java·服务器·开发语言·前端·c++·qt
Tencent_TCB1 天前
AI Coding全流程教程——0基础搭建“MEMO”健康打卡全栈Web应用(附提示词)
前端·人工智能·ai·ai编程·codebuddy·claude code·cloudbase
小猪猪屁1 天前
权限封装不是写个指令那么简单:一次真实项目的反思
前端·javascript·vue.js
hteng1 天前
跨域 Iframe 嵌套:调整内部 Iframe 高度的终极指南 (以及无解的真相)
前端
Polaris_o1 天前
轻松上手Bootstrap框架
前端