<el-table :data="recruitmentList" :default-sort="{prop: 'date', order: 'descending'}" fit style=" 100%"> <el-table-column label="性别要求" prop="genderConstraint" :formatter="typeFormatter"> </el-table-column> </el-table>
data() { return { recruitmentList: [] } }, methods: { typeFormatter: function (row) { switch (row.genderConstraint) { case 0: return "无限制"; case 1: return "男"; case 2: return "女"; } } }
或
<el-table-column label="性别限制"> <template slot-scope="scope"> <span style="margin-left: 10px">{{["无限制", "男", "女"][scope.row.genderConstraint]}}</span> </template> </el-table-column>