> 文档中心 > Vue常见页面(管理+详情+编辑+新增)五、table如何根据状态枚举转换成文字

Vue常见页面(管理+详情+编辑+新增)五、table如何根据状态枚举转换成文字


Vue常见页面(管理+详情+编辑+新增)五、table如何根据状态枚举转换成文字

Vue常见页面(管理+详情+编辑+新增)五、table如何根据状态枚举转换成文字
例如上面这张图,后端接口只给返回了status_yn,是一个枚举,但不是汉字,怎么办

          <el-table  :data="sheetHistory"  stripe  style="width: 54%">  <el-table-column  prop="operator_name"  label="操作人"  width="180">  </el-table-column>  <el-table-column  prop="status_yn"  label="状态"  width="180"  :formatter="stateFormat"  >  </el-table-column>  <el-table-column  prop="description"  label="说明"  width="180">  </el-table-column>  <el-table-column  prop="operate_time"  label="日期"  width="180">  </el-table-column>     </el-table>

methods的stateFormat方法

     stateFormat(row, column){  if(row.status_yn==0){      return '未申请'  }else if(row.status_yn == 1){      return '已申请'  }else if(row.status_yn == 2){      return '申请驳回'  }     }