ElementUI中的 el-table 怎样格式化显示1和0为男和女

在这里插入图片描述

场景

数据库中存储的是int型的1和0。
从数据中取出来的也是1和0。
怎样将其格式化为男和女

实现

//table 表格
<el-table>
<el-table-column prop="type" label="案件类型" :formatter="sfktFormate"></el-table-column>
</el-table>

添加formatter属性对应的sfktFormate是一个方法

//table表格格式化
    sfktFormate(row,index){
    
    
      if (row.type == 1) {
    
    
        return "男";
      } else if(row.type == 0){
    
    
        return "女";
      }
    }

猜你喜欢

转载自blog.csdn.net/sea9528/article/details/108871374