直接上代码
template
<a-row>
<a-col :span="14" class="btnGroup bottom_box">
<div class="rightbox">
<span class="wpccjdde_title once_title">选择派单司机</span>
<a-button @click="lookPb">司机排班</a-button>
</div>
<a-table
:columns="columnstwo"
:customRow="customRow"
:rowKey="(record) => record.driverId"
:dataSource="tableDatatwo"
:pagination="false"
:loading="loadingTwo"
>
<template slot="operation2" slot-scope="text, recode">
<a @click="toLocaltion(recode)">查看</a>
</template>
</a-table>
</a-col>
</a-row>
script
data:{
customKey: -1,
}
methods: {
customRow(record, index) {
return {
style: {
'background-color': record.driverId == this.customKey ? '#0090ff' : '#ffffff',
},
on: {
// 鼠标单击行
click: (event) => {
this.customKey = record.driverId
this.driveInfo = record
},
},
}
},
}
这里的关键点是根据customKey的唯一性去对应的判断显示什么颜色