element表格无数据显示内容自定义
程序员文章站
2022-03-04 11:28:02
...
element表格默认无数据时显示的内容不合适,想要自己定义
- 为表格插入自定义空白内容插槽
<template slot="empty">
</template>
- 在该标签里插入你想要定义的内容
- 可以根据需求调整样式,就放在element表格组件的第一层:如
<el-table :data="tableData" row-key="roleNo" height="calc( 100% - 20px)">
//无数据显示默认图片
<template slot="empty">
<img src="../../assets/images/icon/nodata.png">
</template>
<el-table-column prop="roleName" label="角色名称"></el-table-column>
<el-table-column prop="roleParentName" label="上级角色名称" :formatter="upRoleFormat"></el-table-column>
<el-table-column prop="sys" label="是否系统角色" :formatter="stateFormat"></el-table-column>
<el-table-column prop="dataRange" label="数据范围" :formatter="dataRangeFormat"></el-table-column>
<el-table-column prop="updateTime" label="更新日期"></el-table-column>
<el-table-column prop="creatorName" label="创建人"></el-table-column>
<el-table-column prop="name" label="操作">
<!-- 操作按钮 -->
<template slot-scope="scope">
<el-tooltip
class="item"
effect="dark"
content="查看角色"
placement="bottom"
>
<el-button
type="text"
class="top-right-button"
icon="el-icon-document"
@click="handleDetail(scope.$index, scope.row)"
></el-button>
</el-tooltip>
<el-tooltip
class="item"
effect="dark"
content="编辑角色"
placement="bottom"
>
<el-button
type="text"
class="top-right-button"
icon="el-icon-edit-outline"
@click="handleEdit(scope.row)"
></el-button>
</el-tooltip>
<el-tooltip
class="item"
effect="dark"
content="删除角色"
placement="bottom"
>
<el-button
type="text"
class="top-right-button"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
></el-button>
</el-tooltip>
</template>
</el-table-column>
</el-table>