element表格里数据处理
有时候接口返回的数据是字典码,我们需要进行字典匹配,这时候就要自定义一个方法
html代码
<div> <el-table :data="tableData" border height="300"> <el-table-column type="index" label="序号" align="center" width="70"> <template slot-scope="scope"> {{scope.$index+1}} </template> </el-table-column> <el-table-column prop="userName" label="姓名" align="center"></el-table-column> <el-table-column prop="userSap" label="员工编号" align="center"></el-table-column> <el-table-column prop="userSex" label="性别" align="center" :formatter="userSexdata"></el-table-column> <el-table-column prop="userNation" label="民族" align="center"></el-table-column> <el-table-column prop="userJob" label="工作岗位" align="center"></el-table-column> </el-table> </div>
script代码
userSexdata(row, column, cellValue){ console.log("输出每一行",row,column,cellValue) if(cellValue== 'xb_002' ){ return "女" }else{ return "男" }
},