reactjs - 如何启用禁用列表项中的按钮
解决方案
ListItemButton
which is disabled 已pointer-events
设置为,none
因此您无法单击其中的任何内容。要解决该问题,请再次覆盖您的内部按钮:
V5
import Button, { buttonClasses } from "@mui/material/Button";
<List
sx={{
[`&& .${buttonClasses.disabled}`]: {
opacity: 1,
// anything that's not a button inside ListItem
[`& > :not(.${buttonClasses.root})`]: {
opacity: (theme) => theme.palette.action.disabledOpacity
},
// inner button
[`& > .${buttonClasses.root}`]: {
pointerEvents: "auto"
}
}
}}
>
V4
const useStyles = makeStyles(theme => ({
list: {
'&& .Mui-disabled': {
opacity: 1,
'& > :not(.MuiButton-root)': {
opacity: theme.palette.action.disabledOpacity
},
'& > .MuiButton-root': {
pointerEvents: "auto"
},
},
}
}));
<List className={classes.list}
推荐阅读
- python - TypeError:即使我没有,也不能将序列乘以“numpy.float64”类型的非整数
- postgresql - 如何在 Postgres 中删除区分大小写?
- ios - 如何使用 Firestore 对象数据填充 tableview
- liferay - Liferay 6.2 身份验证挂钩迁移到 Lr 7.2 片段?
- flutter - 我对进度指示器有疑问,因为在发送 HTTP 请求时指示器未更新状态
- python - Discord重写警告系统
- java - Java如何打印数组?
- python - 如何修复“无法执行脚本”错误
- c# - MvvmCross + Xamarin.Forms“没有隐式引用转换......”
- amazon-web-services - 为什么在此 AWS Lambda 部署包中找不到处理程序脚本?