vue2+element ui 中的el-table 选中当前行当前行变色

javascript 复制代码
 <el-table class="eltable" ref="multipleTable" :data="tableData" style="margin-top: 50px;width: 100%;"
                    :row-class-name="tableRowClassName" @row-click="rowClick">
                    <el-table-column v-for="(item, index) in tableTitleList" :label="item.name" :key="index"
                        :prop="item.prop" :width="item.width" align="center">
                    </el-table-column>
                </el-table>

方法:

javascript 复制代码
   rowClick(row, column, event) {
            
            console.log(row,column);
            this.selectIndex = row.index;
        },
        // 行选中样式
        tableRowClassName({
            row,
            rowIndex
        }) {
            row.index = rowIndex 
            if (rowIndex == this.selectIndex) {
                return 'success-row';
            }
        },

样式:

javascript 复制代码
::v-deep .success-row {
    background-color: #81D3F8 !important;
}
相关推荐
yinuo2 分钟前
CSS基础动画keyframes
前端
一条上岸小咸鱼44 分钟前
Kotlin 基本数据类型(一):Numbers
android·前端·kotlin
前端小巷子1 小时前
Vue 事件绑定机制
前端·vue.js·面试
uhakadotcom1 小时前
开源:subdomainpy快速高效的 Python 子域名检测工具
前端·后端·面试
爱加班的猫1 小时前
Node.js 中 require 函数的原理深度解析
前端·node.js
用户8165111263971 小时前
WWDC 2025 Build a SwiftUI app with the new design
前端
伍哥的传说1 小时前
Vue 3.5重磅更新:响应式Props解构,让组件开发更简洁高效
前端·javascript·vue.js·defineprops·vue 3.5·响应式props解构·vue.js新特性
阅文作家助手开发团队_山神2 小时前
第一章: Mac Flutter Engine开发准备工作
前端·flutter
菜牙买菜2 小时前
Hicharts入门
前端·vue.js·数据可视化