项目中,有时候需要实现如下效果:
关键代码如下:
<el-table stripe
:data="tableData"
class="el-table-scrollable-y"
:span-method="objectSpanMethod"
border
style="width: 100%"
>
<el-table-column
prop="name"
width="260"
label="指标名称">
</el-table-column>
<el-table-column
prop="evaluationTypeDesc"
label="分类">
</el-table-column>
<el-table-column
prop="isCheck"
width="80"
label="是否考核">
<template slot-scope="scope">
<div class="check-div"
:class="scope.row.isCheck==1?'checked':''"
></div>
</template>
</el-table-column>
<el-table-column
prop="checkCriteriaValue"
:formatter="bzFormatter"
width="80"
label="考核标准">
</el-table-column>
</el-table>
// methods中添加对应的方法
methods: {
bzFormatter(row, column) {
let fh = row.direction == 1?'≥':'≤'
let result = row.checkCriteriaValue?`${fh}${row.checkCriteriaValue}${row.unit}`:''
return result
},
}