iis服务器助手广告广告
返回顶部
首页 > 资讯 > 前端开发 > JavaScript >ElementUI中利用table表格自定义表头Tooltip文字提示
  • 866
分享到

ElementUI中利用table表格自定义表头Tooltip文字提示

2024-04-02 19:04:59 866人浏览 八月长安
摘要

目录实现效果ElementUI文档el-table组件tooltip组件render-header绑定的方法实现效果 ElementUI文档 el-table组件 <e

实现效果

ElementUI文档

el-table组件

  <el-table-column label="水位高程(m)" header-align="center" align="center">
          <el-table-column
            prop="swlel"
            label="传感器监测"
            align="center"
            :render-header="(h, { column }) => renderHeaderMethods(h, { column }, '来源:传感器监测数据')"
          ></el-table-column>
          <el-table-column
            prop="mwlel"
            label="人工监测计算"
            align="center"
            :render-header="(h, { column }) => renderHeaderMethods(h, { column }, '人工监测计算=测点孔口高程-绳长')"
          ></el-table-column>
        </el-table-column>
        <el-table-column
          prop="error"
          label="误差"
          align="center"
          :render-header="(h, { column }) => renderHeaderMethods(h, { column }, '误差=人工监测计算(水位高程)-传感器监测(水位高程)')"
        ></el-table-column>

tooltip组件

<template>
  <div class="tooltip">
    <el-tooltip placement="bottom" popper-class="atooltip" :visible-arrow="false">
      <div slot="content">
        <!-- 插槽,可提供多行的提示信息 -->
        <!-- 全局组件,这里是配置图标icon和提示信息的地方 -->
        <!-- 在其他组件中引用方式详见 table-header-tips.Vue 组件中的 renderHeaderMethods 方法 -->
        <p v-for="(item, index) in messages" :key="index">{{ item }}</p>
      </div>
      <i class="el-icon-warning-outline" style="color: red; margin-left: 5px"></i>
    </el-tooltip>
  </div>
</template>
<script>
export default {
  name: 'SpmonTootip',
  data() {
    return {}
  },
  props: {
    messages: {
      type: Array,
      default() {
        return []
      }
    }
  }
}
</script>
<style lang="sCSS">
.tooltip{
  padding: 0 !important;
}
.atooltip.el-tooltip__popper[x-placement^='right'] .popper__arrow {
  border-top-color: rgba(112, 182, 3, 0.811764705882353);
  color: #fff;
}
.atooltip.el-tooltip__popper[x-placement^='right'] .popper__arrow:after {
  border-top-color: rgba(112, 182, 3, 0.811764705882353);
  color: #fff;
}
.atooltip {
  background: rgba(112, 182, 3, 0.811764705882353) !important;
  color: #fff !important;
}
</style>

render-header绑定的方法

 // 自定义表格
    // 例如:给表头 地址 加一个 icon,鼠标移入icon展示提示信息
    renderHeaderMethods(h, { column }, message) {
      return h('div', { style: 'display:inline-block;margin:auto;' }, [
        h('span', column.label),
        h('SpmonTootip', {
          // 引用组件
          props: {
            // messages 里面配置的信息即为 Tooltip 提示信息
            messages: [message]
          }
        })
      ])
    },

以上为个人经验,希望能给大家一个参考,也希望大家多多支持编程网。

--结束END--

本文标题: ElementUI中利用table表格自定义表头Tooltip文字提示

本文链接: https://www.lsjlt.com/news/165574.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作