问题
AutoComplete uses Menu to render MenuItems as shown in the docs on those pages.
I need to change the backgroundColor of the hovered MenuItem. I am able to change color of all items by using "menuItemStyle" which expects a style object but I'm not sure what the syntax for hover style is in the Material-UI style objects.
回答1:
They are still working on hoverColor which is possible in List Item. But for the time being you can use these Props
<MenuItem
primaryText="MenuItem"
onMouseEnter={(e) => e.target.style.backgroundColor= 'red'}
onMouseLeave={(e) => e.target.style.backgroundColor = '#ffffff'}/>
This might fix your problem temporarily.
回答2:
Applying hover style on root should do it.
const MyMenuItem = withStyles({
root: {
'&:hover': {
backgroundColor: 'red !important',
color: 'blue'
}
}
})(MenuItem)
来源:https://stackoverflow.com/questions/45536092/how-do-i-change-material-ui-menuitem-background-on-hover-change-from-autocomplet