elementui中table标题和内容插槽

代码

<template>  
  <el-table :data="tableData">  
    <el-table-column>  
      <template slot="header" slot-scope="scope">  
        <el-tooltip content="这是列的提示信息" placement="top">  
          <span>列标题</span>  
        </el-tooltip>  
      </template>  
      <template slot-scope="scope">  
        <!-- 列内容 -->  
        {{ scope.row.someProperty }}  
      </template>  
    </el-table-column>  
    <!-- 其他列 -->  
  </el-table>  
</template>  
  
<script>  
export default {  
  data() {  
    return {  
      tableData: [  
        // ... 数据  
      ]  
    };  
  }  
};  
</script>

使用原因:el-table中标题内容过长,设置隐藏,并鼠标悬停可以显示内容

用到知识点:html中的title和css的样式

关键代码:

css设置 

/deep/ .el-table th.el-table__cell > .cell {
  border: 1px solid red;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-block;
}

html

 <el-table-column
            prop="product"
            :label="$t('projectMgr.table.product')"
            align="center"
          >
            <template slot="header" slot-scope="scope">
              <el-tooltip
                :content="$t('projectMgr.table.product')"
                placement="top"
              >
                <span>{{ $t('projectMgr.table.product') }}</span>
              </el-tooltip>
            </template>
            <template slot-scope="scope">
              <el-tag
                v-if="scope.row.isProductFamilyManagementEnabled === 1"
                type="success"
                >{{ $t('projectMgr.duoPro') }}
              </el-tag>
              <el-tag v-else>{{ $t('projectMgr.danPro') }}</el-tag>
            </template>
          </el-table-column>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值