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;
}
相关推荐
用户938515635076 分钟前
Type vs Interface:读完这篇就没有面试官能难倒你了
前端·面试·typescript
用户9385156350716 分钟前
手写一个 LLM Harness 框架:用工程化手段把大模型幻觉踩在脚下
javascript·人工智能·后端
油丶酸萝卜别吃1 小时前
jquery-ajax.js 说明文档
前端·javascript·jquery
windliang1 小时前
Claude Code 源码分析(九):子 Agent 如何分叉、继续与回到父会话
前端·javascript·面试
柒和远方2 小时前
V063: TS 面试必考:interface 与 type 的四大差异,与 LLM Harness 的自动化择优
前端·javascript
半个落月2 小时前
React useRef 详解:DOM 引用、持久化值与 Worker 实例
前端·react.js
阿黎梨梨2 小时前
TypeScript 类型编程:从新手到 Harness 工程实践
前端
黄金决明子2 小时前
Vue3 + Vite 打包后打开空白?
前端
张龙6872 小时前
终端效率翻倍实战:fzf + zoxide + ripgrep + bat 组合拳,告别重复敲命令
前端
宿6742 小时前
vue3-env环境
前端·vue.js