<el-table ref="voiceTable"
          :data="tableData"
          @select="getSelectData"
          @select-all="getAllSelectedData"
          :header-cell-class-name="setCheckallStyle"
          :row-style="rowClass"> // 重点在这里
/**
 * 选中/取消某行时改变其背景色
 */
rowClass({row, rowIndex}) {
  if (this.finInvoiceUuidList.includes(row.uuid)) {  //①
    return { "background-color": "rgba(185, 221, 249, 0.75)" };
  } else {
    return '';
  }
}

①:每行数据都有一个业务属性uuid,而且是全局唯一。finInvoiceUuidList用于保存已选中行对应的uuid。

Logo

讨论HarmonyOS开发技术,专注于API与组件、DevEco Studio、测试、元服务和应用上架分发等。

更多推荐