我正在使用material-table并尝试对我当前悬停的行实施突出显示。
该文档仅提供了onRowClick第三个示例中操作的颜色更改:
function SelectedRowStyling() {
const { useState } = React;
const [selectedRow, setSelectedRow] = useState(null);
return (
<MaterialTable
title="Selected Row Styling Preview"
columns={[
{ title: 'Name', field: 'name' },
{ title: 'Surname', field: 'surname' },
{ title: 'Birth Year', field: 'birthYear', type: 'numeric' },
{
title: 'Birth Place',
field: 'birthCity',
lookup: { 34: 'İstanbul', 63: 'Şanlıurfa' },
},
]}
data={[
{ name: 'Mehmet', surname: 'Baran', birthYear: 1987, birthCity: 63 },
{ name: 'Zerya Betül', surname: 'Baran', birthYear: 2017, birthCity: 34 },
]}
onRowClick={((evt, selectedRow) => setSelectedRow(selectedRow.tableData.id))}
options={{
rowStyle: rowData => ({
backgroundColor: (selectedRow === rowData.tableData.id) ? '#EEE' : '#FFF'
})
}}
/>
)
}
我阅读了props源代码中的可用内容,但没有找到类似onRowHover. 尝试了一些ThemeProvider解决方案,但没有成功,我如何通过悬停动作实现颜色变化?
