今天记录一下关于使用el-table的时候,空的表格项使用"——"符号或者别的标记符号展示是如何实现的。
两种方法,一是通过template标签,二是通过css伪类:empty选择器
1、template标签
<el-table-column label="操作时间">
<template slot-scope="scope">{{scope.row.time? scope.row.time: '--'}}</template>
</el-table-column>
2、css伪类:empty选择器
给el-table设置class名称,根据名称去设置相应的css样式
<el-table :data="tableData" class="tableData">
<el-table-column type="index" label="序号" width="100"/>
....
<el-table-column property="lastlogin" label="最后操作时间"/>
</el-table>
css:
/* 表格数据为空时显示——*/
.tableData :empty::before{
content:'——';
}
效果: