el-table点击添加行样式

这篇博客详细介绍了如何使用Element UI库来创建一个具有自定义边框颜色、字体样式、背景色以及鼠标悬停效果的表格。通过设置`el-table`的属性,如`:cell-style`和`:header-cell-style`,可以实现行和头部单元格的个性化样式。同时,通过`:row-class-name`和`@row-click`事件监听,实现了行点击时的高亮效果和相应的回调函数处理。
摘要由CSDN通过智能技术生成
  <el-table
        :data="tableData"
        border
        :max-height="200"
        :style="{
          borderColor: showPanelTableStyle.borderColor,
          width: `210px`,
        }"
        :cell-style="{
          borderColor: showPanelTableStyle.borderColor,
          fontFamily: showPanelTableStyle.cellFontFamily,
          fontSize: `${showPanelTableStyle.cellFontSize}px`,
          color: showPanelTableStyle.cellFontColor,
          backgroundColor: showPanelTableStyle.cellBgColor,
          padding: 0,
          height: `40px`,
        }"
        :header-cell-style="{
          borderColor: showPanelTableStyle.borderColor,
          fontFamily: showPanelTableStyle.headerFontFamily,
          fontSize: `${showPanelTableStyle.headerFontSize}px`,
          color: showPanelTableStyle.headerFontColor,
          backgroundColor: showPanelTableStyle.headerBgColor,
          padding: 0,
          height: '40px',
        }"
        :row-class-name="tableRowClassName"
        @row-click="onRowHandler($event)"
      >
      </el-table>
 	:row-class-name="tableRowClassName"

    tableRowClassName({ row, rowIndex }) {
      if (!this.vueData) return;
      // 当前选中行id 与 表格的各行比较
      if (this.vueData.currentDataId == row.id) {
        return "success-row";  
      }
      return "";
    },
.success-row {
  background: #0c90b8;
}

el-table鼠标经过,行样式

.el-table tbody tr:hover>td { 
  background-color:rgba(220, 220, 220, 0.2)!important;
  color:#000
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值