【UI】 element ui 表格没有数据时用--填充

具体效果

在这里插入图片描述

实现代码

第一种方法 加class类名

style中

  .table :empty::before {
    content: "--";
    color: gray;
  }

注意:如果使用了switch滑块steps步骤条等,可能也会被加上--,效果就变成了

在这里插入图片描述

解决
template中,给switch滑块加class

      <el-table-column label="状态" width="90" prop="status" align="center">
        <template slot-scope="scope">
          <el-switch
            v-model="scope.row.status"
            @change="statusMonitor(scope.$index, scope.row)"
            :active-value="0"
            :inactive-value="1"
            class="status" 
          >
          </el-switch>
        </template>
      </el-table-column>

style中

  .status :empty::before {
    content: "";
    color: red;
  }

第二种方法 template中

 <el-table-column label="维护开始时间" align="center" width="180">
   <template slot-scope="scope">{{
     scope.row.startTime ? scope.row.startTime : "--"
   }}</template>
 </el-table-column>

下班~

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 4
    评论
引用\[1\]中的代码展示了一个使用Element UI表格组件,并通过cellStyle方法来设置表格单元格的样式。在这个例子中,如果amount1大于300,则将单元格的背景色设置为红色,并将文字颜色设置为白色。如果amount2小于3,则将单元格的背景色设置为红色,并将文字颜色设置为白色。 引用\[2\]中的代码展示了一个使用Element UI表格组件的模板代码。在这个例子中,通过:cell-style属性将cellStyle方法绑定到表格组件上,以实现单元格样式的设置。 引用\[3\]中的代码展示了另一种实现方式,通过:row-class-name属性来设置行的样式类名,从而实现表格填充颜色的效果。 综上所述,要实现Element UI表格填充颜色效果,可以使用cellStyle方法或row-class-name属性来设置单元格或行的样式。具体的实现方式可以根据实际需求选择。 #### 引用[.reference_title] - *1* *2* [element UI表格变成红色](https://blog.csdn.net/qq_41648113/article/details/109337781)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [如何给基于Element-UI表格添加背景颜色](https://blog.csdn.net/weixin_45681173/article/details/125084532)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

fruge365

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值