el-table内容为空,设置默认值
效果
方法一:通过css设置
/deep/.el-table {
.cell:empty::before {
content: "---";
color: #ccc;
}
.is-leaf {
.cell:empty::before {
content: "---";
color: #ccc;
}
}
}
方法二:过滤
在el-table-column
里使用:formatter
<el-table-column
prop="caseTypeNames"
label="类型"
:formatter="caseTypeNamesFormat"
>
</el-table-column>
// 类型格式化
caseTypeNamesFormat (row) {
let showProp = null
row.caseTypeNames ? showProp = row.caseTypeNames : showProp = '---'
return showProp
},