使用Material UI组件时,如果需要添加ARIA属性,可以使用props
中提供的aria-
前缀属性覆盖默认属性,例如aria-label
、aria-disabled
等。以下为代码示例:
import Button from '@material-ui/core/Button';
function MyButton() {
return (
);
}
在上述代码中,我们为按钮组件添加了aria-label
属性,覆盖了默认的aria-haspopup
属性。这样做可以确保ARIA属性与Material UI组件兼容。