antd 表格ellipsis 与 scopedSlots 一起使用

本文介绍了前端模板中不同情况的数据渲染方式,包括信息展示的省略号处理、鼠标悬停显示完整内容的实现、过滤器的使用以及循环渲染数据的方法。详细探讨了如何通过调整样式和使用条件来控制内容的显示效果,如信息的折叠和展开,以及如何在有限的空间内展示丰富信息。
摘要由CSDN通过智能技术生成
1、第一种情况,超出有省略号,但鼠标移上去不显示内容

在这里插入图片描述

<template slot="information" slot-scope="text, record">
  <span>测站编码:{{ record.stationCode }}</span
  ><br />
  <span>测站名称:{{ record.stationName }}</span
  ><br />
  <span>测站区域:{{ record.stationRegion }}</span>
</template>
{
  title: "测站信息",
  scopedSlots: { customRender: "information" },
  ellipsis: true
},
2、第二种情况,没有省略号,但鼠标移上去显示内容

在这里插入图片描述

<span slot="deviceInfo" slot-scope="record" class="infoBox">
  <span>设备编码:{{ record.deviceCode }}</span>
  <span :title="record.manufacturesName">设备厂家:{{ record.manufacturesName }}</span>
  <span>设备类型:{{ record.deviceTypeName }}</span>
  <span>设备型号:{{ record.deviceModelName }}</span>
</span>
{
  title: "设备信息",
  scopedSlots: {
    customRender: "deviceInfo",
  },
  ellipsis: true,
},
3、第三种,显示省略号和鼠标移上去显示全部信息

在这里插入图片描述

<template slot="deviceInfo" slot-scope="record">
  <span :title="record.deviceCode">设备编码:{{ record.deviceCode }}</span>
  <br />
  <span :title="record.manufacturesName">设备厂家:{{ record.manufacturesName }}</span>
  <br />
  <span :title="record.deviceTypeName">设备类型:{{ record.deviceTypeName }}</span>
  <br />
  <span :title="record.deviceModelName">设备型号:{{ record.deviceModelName }}</span>
</template>
{
  title: "设备信息",
  scopedSlots: {
    customRender: "deviceInfo",
  },
  ellipsis: true,
},
4、细心的朋友会发现,其实第二种是被样式影响了(使用span标签,块级元素会影响哦)
// 表格内信息
.infoBox {
  display: flex;
  flex-direction: column;
}
5、还有一种情况,使用了过滤器渲染数据
<span slot="type" slot-scope="text">
  <span :title="text | showType">{{ text | showType }}</span>
</span>

filters: {
  showType(val) {
    switch (val) {
      case 0:
        return '勘察调研上报'
      case 100:
        return '施工情况上报'
      case 300:
        return '运维信息上报'
      case 301:
        return '巡检'
      case 302:
        return '设备校准'
      case 303:
        return '临时性计划'
      case 304:
        return '告警'
      default:
        return '--'
        break;
    }
  }
},

在这里插入图片描述

6、又遇到另一种新情况,通过循环渲染的数据
<template #conditions="{record}">
  <span
    v-for="(item, index) in record.conditionList"
      :key="index + 1"
  >
    <span :title="(index + 1 == 1?'①': index + 1 == 2?'②': index + 1 == 3?'③': index + 1 == 4? '④': '⑤') + item.name + item.exp + item.value + item.unit + item.dataReportName + item.cycleName">
      <span v-if="index + 1 == 1">①</span>
      <span v-if="index + 1 == 2">②</span>
      <span v-if="index + 1 == 3">③</span>
      <span v-if="index + 1 == 4">④</span>
      <span v-if="index + 1 == 5">⑤</span>
      <span>{{ item.name }}</span>
      <span>{{ item.exp }}</span>
      <span>{{ item.value }}</span>
      <span>{{ item.unit }}</span>
      <span>{{ item.dataReportName }}</span>
      <span>{{ item.cycleName }}</span>
    </span>
    <br />
  </span>
</template>

在这里插入图片描述

人因热爱生活而更容易被治愈!

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值