给el-table表头添加icon图标,以及鼠标移入icon时显示el-tooltip提示内容

第一种方法 (推荐) :
在这里插入图片描述
完整代码:

<template>
  <div class="container">
    <el-table :data="tableData">
      <el-table-column prop="test1" align="center">
        <template slot="header">
          <span>测试1</span>
          <el-tooltip popper-class="tooltip" placement="top">
            <i class="el-icon-warning-outline"></i>
            <div slot="content" class="tooltip-content">
              <div>1、测试内容测试内容测试内容,</div>
              <div class="indent">测试内容测试内容测试内容。</div>
              <div>2、测试内容测试内容测试内容</div>
              <div>3、测试内容测试内容测试内容</div>
            </div>
          </el-tooltip>
        </template>
      </el-table-column>
      <el-table-column label="测试2" prop="test2" align="center"></el-table-column>
    </el-table>
  </div>
</template>
<script>
export default {
  data() {
    return {
      tableData: [{ test1: "1", test2: "2" }],
    };
  },
};
</script>
<style lang="scss" scoped>
/deep/ .el-table {
  width: 500px;
  margin-top:300px;
  border: 1px solid #eee;
}
//下面样式一定需要写在最外层,不能嵌套在el-table或其他样式里面
.tooltip-content {
  div {
    line-height: 18px;
  }
  div:nth-child(3){
    padding:5px 0;
  }
  .indent{
    text-indent: 20px;
  }
}
</style>

参考链接:https://blog.csdn.net/weixin_45899022/article/details/104291057

  • 3
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值