el-table/avue-crud统一设置鼠标选中和经过背景色变化

效果图:在这里插入图片描述
首先是关于鼠标经过背景色改变的修改

1.所有页面鼠标经过样式修改(style下common文件中):

//  表格经过
.el-table--enable-row-hover .el-table__body tr:hover>td{
  background-color: #c8e2f7 !important;
}

2.avue-crud的样式:

 .el-table__body .el-table__row.hover-row td {
  background-color:#c8e2f7!important;
} 

表格选中背景色改变

1.首先在main.js中挂载公共方法

// 单击选中背景色
Vue.prototype.$rowStyle = function (row, selected) {
  if (!selected.length)  return  { 'background-color': '#fff' }
  const arr = selected.map(item => item.id)
  if ( arr.includes(row.id)) {
    return  { 'background-color': '#cad7f7' }
  } 
}

2.在表格中使用
选中行样式以及单击选中的实现,selectionList当前表格选中数据

 :row-style="({ row }) => $rowStyle(row, selectionList)"
 @row-click="(row)=> $refs.crud.toggleRowSelection(row)"

在这里插入图片描述

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值