我认为你可以为 Link 组件使用 styled-components
。像这样……
const theme = useTheme();
const StyledLink = styled(Link)(({ theme, color = 'primary' }) => ({
":hover": {
color: theme.palette.secondary.main,
},
}));
<Button
color="primary"
href="/apiproxy/objects/1/subobjects"
LinkComponent={React.forwardRef((props, ref) => (
<StyledLink
{...props}
type="text/csv"
download="object_1_subobjects.csv"
ref={ref}
theme={theme}
/>
))}
/>
你可以在 theme.js 文件中设置调色板中的悬停颜色,并像这样使用该颜色:theme.palette.{hoverColor}
。
请检查这个测试组件。
链接