elementui Table的表头内容过长改为......并提示

一、效果图

在这里插入图片描述

二、代码

我的el-table-column是通过遍历出来的,设置默认width,然后回调render-header

<!-- 测试过滤字段 -->
      <el-table-column 
        v-for="item in clientTranslate" 
        :prop="item.fileterFieldName" 
        :label='item.fileterEnName' 
        :key="item.fileterId"
        v-if="item.isHide"
        width="110px"
        align="center"
        :render-header="tableRenderHeader"  
        show-overflow-tooltip sortable 
      >
        <template slot-scope="scope">
            <span v-if="item.fileterFieldName == 'clientCode'" ><el-link type="primary" @click="opdenDrawer(scope.$index,scope.row,true)">{{ scope.row.clientCode }}</el-link></span>
            <span v-else-if="item.fileterFieldName == 'clientNameEn'" ><el-link type="primary" @click="opdenDrawer(scope.$index,scope.row,true)">{{ scope.row.clientNameEn }}</el-link></span>
            <span v-else-if="item.fileterFieldName == 'clientNameChs'" ><el-link type="primary" @click="opdenDrawer(scope.$index,scope.row,true)">{{ scope.row.clientNameChs }}</el-link></span>
            <span v-else-if="item.fileterFieldName == 'isLock'" ><i :class="scope.row.isLock===1?'el-icon-lock':''" :style="scope.row.isLock===1?'color:red':'color:'" /></span>
            <span v-else-if="item.fileterFieldName == 'isSuccessDeal'" ><i :class="scope.row.isSuccessDeal===1?'el-icon-success':'el-icon-error'" :style="scope.row.isSuccessDeal===1?'color:green':'color:red'" />{{ scope.row.isSuccessDeal===1?'成交':'未成交' }}</span>
            <span v-else-if="item.fileterFieldName == 'isDel'" ><i :class="scope.row.isDel===1?'el-icon-delete-solid':'el-icon-success'" :style="scope.row.isDel===1?'color:red':'color:green'" />{{ scope.row.isDel===1?'归档':'正常' }}</span>
            <span v-else-if="item.fileterFieldName == 'isStar'" >
              <el-tooltip :content="scope.row.isStar == 0?'添加关注':'取消关注'" placement="top" :disabled="!fromTodoWork.btnGeneral_Show">
                <i class="el-icon-star-on focus-icon" :style="{color:scope.row.isStar == 0 ? iconColor = '#d9d9d9':iconColor = '#fac23d'}" @click="fromTodoWork.btnGeneral_Show==false?false:iconCheck(scope.row)"></i>
              </el-tooltip>
            </span>
            <span v-else>
              {{scope.row[item.fileterFieldName]}}
            </span>
        </template>
      </el-table-column>
methods: {
    // 表头固定
    tableRenderHeader(h,data){
      return h('span',[
        h('el-tooltip',{
          attrs:{
            class:"item",
            effect:'dark',
            content:data.column.label,
            placement:'top'
          }
        },[
          h('span',data.column.label)
        ])
      ])
    }
   }
<style lang="less" scoped>
  // 表头固定
  /deep/ .el-table th.el-table__cell > .cell {
    white-space: pre;
    // white-space: pre-wrap; // 也行。
  }
 }
  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值