slot-scope插槽搭配filters的使用
先来定义一个插槽
<el-table-column label="聘用形式">
<template slot-scope="scope">
形式:{{ scope.row.formOfEmployment }}
</template>
</el-table-column>
定义filters
filters: {
// 这里的val是得到的数据
screenEmployment(val) {
if (val === 1) {
return '正式'
} else {
return '非正式 '
}
}
},
给插槽添加上过滤器
<el-table-column label="聘用形式">
<template slot-scope="scope">
形式:{{ scope.row.formOfEmployment | screenEmployment }}
</template>
</el-table-column>
效果图: