猿问

element中表格的多选事件,怎么实现选中该行,对应该行的颜色发生变化

当我选中这几条数据的时候,这几行的颜色都发生变化,当取消的时候,颜色恢复正常。给表格加了高亮了,在多选事件@select-change=“selectChange”
selectChange: function (val) {
this.currentRow = val
}
但是和多选事件没联系起来,只有点击这一行的时候 发生高亮
刚发现高亮是针对当前行的,那不用高亮的话,针对多选,多行颜色发生变化,怎么实现呢

烙印99
浏览 1976回答 4
4回答

噜噜哒

用row-style或row-class-name给所选行添加样式&nbsp; <el-table&nbsp; &nbsp; ref="table"&nbsp; &nbsp; :data="tableData"&nbsp; &nbsp; border&nbsp; &nbsp; :row-style="selectedHighlight"&nbsp; &nbsp; @selection-change="handleSelectionChange"&nbsp; >&nbsp; methods: {&nbsp; &nbsp; selectedHighlight(row) {&nbsp; &nbsp; &nbsp; if ( /*row is selected*/ ) {&nbsp; &nbsp; &nbsp; &nbsp; return {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "background-color": "black"&nbsp; &nbsp; &nbsp; &nbsp; };&nbsp; &nbsp; &nbsp; &nbsp; return {}&nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; },见element文档

白猪掌柜的

因为你每一次选择都重置了一次啊
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答