我想覆盖主题中选择字段下拉列表的位置(不必在每个选择上实现它)。
我尝试过:
createMuiTheme({
overrides: {
MuiSelect: {
select:{
MenuProps: {
getContentAnchorEl: null,
anchorOrigin: {
vertical: "bottom",
horizontal: "left",
}
}
}
}
}
}
});
下拉菜单的位置不会被覆盖。
我也尝试更换select
by selectMenu
但什么也没发生...
当我直接传递给组件道具时,它正在工作:
<Select
...otherProperties,
MenuProps={{
getContentAnchorEl: null,
anchorOrigin: {
vertical: "bottom",
horizontal: "left",
}
}}
>
...childs
</Select>
我怎样才能实现覆盖所有选择的这个道具?
有关我正在使用的信息:
"react": "^16.12.0",
"@material-ui/core": "^4.9.10",
"typescript": "3.6.3",
提前致谢
The 覆盖键 https://material-ui.com/customization/globals/#css用于覆盖样式。您应该使用道具键 https://material-ui.com/customization/globals/#default-props用于默认主题中的道具。
这是正确的语法:
const theme = createMuiTheme({
props: {
MuiSelect: {
MenuProps: {
getContentAnchorEl: null,
anchorOrigin: {
vertical: "bottom",
horizontal: "left"
}
}
}
}
});
相关回答:是否可以覆盖material-ui组件的默认道具? https://stackoverflow.com/questions/57359439/is-it-possible-to-override-material-ui-components-default-props/57360023#57360023
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)