vite 项目 vxeTable表格多行省略,并bootstrap框架 tooltip显示全部内容

需求

vue3项目中,使用了vxeTable和bootstrap组件,在使用表格时,当内容多行省略时,tooltip显示全部内容

vue模板

<vxe-table
  border
  :scroll-y="{ enabled: false }"
  :row-config="{ isHover: true }"
  :align="'center'"
  class="penalty-table"
  :data="list"
>
  <vxe-column field="illegalFact" title="姓名" show-overflow="tooltip">
    <template #default="{ row }">
      <span
        :id="'illegal-fact-' + row.id"
        class="illegal-fact-tooltip element"
        data-bs-toggle="tooltip"
        data-bs-placement="top"
        :data-bs-title="row.illegalFact"
        @mouseenter="showTooltip('illegal-fact-' + row.id)"
        @mouseleave="hideTooltip('illegal-fact-' + row.id)"
      >
        {{ row.illegalFact }}
      </span>
    </template>
  </vxe-column>
  <vxe-column field="penaltyCode" title="性别"></vxe-column>
  <vxe-column field="penaltyGist" title="测试" show-overflow="tooltip">
    <template #default="{ row }">
      <span
        :id="'penalty-gist-' + row.id"
        class="illegal-fact-tooltip element"
        data-bs-toggle="tooltip"
        data-bs-placement="top"
        :data-bs-title="row.penaltyGist"
        @mouseenter="showTooltip('penalty-gist-' + row.id)"
        @mouseleave="hideTooltip('penalty-gist-' + row.id)"
      >
        {{ row.penaltyGist }}
      </span>
    </template>
  </vxe-column>
  <template #empty>
    <span style="display: inline-block; height: 300px">
      <img
        src="@/assets/images/emptyIcon.png"
        style="margin-top: 50px"
        alt="图片"
        @error.once="setDefaultImage"
      />
      <p>没有更多数据了!</p>
    </span>
  </template>
</vxe-table>

ts代码

const showTooltip = (id: any) => {
  if (
    (document.getElementById(id)?.scrollHeight as number) >
    (document.getElementById(id)?.offsetHeight as number)
  ) {
    $('.table-row  #' + id).tooltip()
    $('.table-row  #' + id).tooltip('show')
  }
}

const hideTooltip = (id: any) => {
  if (
    (document.getElementById(id)?.scrollHeight as number) >
    (document.getElementById(id)?.offsetHeight as number)
  ) {
    $('.table-row  #' + id).tooltip('hide')
  }
}

scss代码

:deep(.vxe-table--render-default .vxe-body--column.col--ellipsis:not(.col--actived) > .vxe-cell) {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: normal;
  max-height: none;
}
  • 10
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值