当获取后台数据为空时,列表显示默认空图片,不正确姿势:
<el-table
v-loading="isLoading"
:data="deviceListData"
style="width: 100%"
:header-cell-style="headStyle"
row-key="id"
@row-click="handleTabSel"
>
<template v-if="deviceListData.length">
<el-table-column prop="name" label="设备名称"> </el-table-column>
<el-table-column prop="id" label="设备ID"> </el-table-column>
<el-table-column prop="online" label="在线状态"> </el-table-column>
<el-table-column prop="1656121597" label="激活时间"> </el-table-column>
<el-table-column label="操作">
<div class="op-wrapper">
<div @click="editDevice" class="edit">编辑</div>
<div @click="controlDevice" class="edit">控制</div>
<div @click="deleteDevice" class="edit">移除</div>
</div>
</el-table-column>
</template>
<el-empty v-else image-size="60"></el-empty>
</el-table>
发现el-empty 默认空图片一直显示不出来,还以为el-empty用法有问题,弄了个空页面,直接加载el-empty 发现没有问题。查了一下原来el-table 数据为空时,显示默认图片写法不对,正确姿势如下:文章来源:https://www.toymoban.com/news/detail-535958.html
<el-table
v-loading="isLoading"
:data="deviceListData"
style="width: 100%"
:header-cell-style="headStyle"
row-key="id"
@row-click="handleTabSel"
>
<el-table-column prop="name" label="设备名称"> </el-table-column>
<el-table-column prop="id" label="设备ID"> </el-table-column>
<el-table-column prop="online" label="在线状态"> </el-table-column>
<el-table-column prop="1656121597" label="激活时间"> </el-table-column>
<el-table-column label="操作">
<div class="op-wrapper">
<div @click="editDevice" class="edit">编辑</div>
<div @click="controlDevice" class="edit">控制</div>
<div @click="deleteDevice" class="edit">移除</div>
</div>
</el-table-column>
<template slot="empty">
<el-empty image-size="60"></el-empty>
</template>
</el-table>
这样就能正常显示el-emtpy 默认空图片了。文章来源地址https://www.toymoban.com/news/detail-535958.html
到了这里,关于element ui el-table 无数据时显示默认空图片(el-empty)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!