如何在 ReactJS Material UI 中使用 useStyle?

我做了一个单独的useStyle文件,想在material ui的useStyle中使用这个自定义的css。如何实现?


input[type="checkbox"],

input[type="radio"] {

  display: none;

}


绝地无双
浏览 159回答 1
1回答

三国纷争

假设您的useStyles文件看起来像这样:import makeStyles from "@material-ui/core/styles/makeStyles";const useStyles = makeStyles({&nbsp; hideCheckboxAndRadio: {&nbsp; &nbsp; "& input[type='checkbox'], & input[type='radio']": {&nbsp; &nbsp; &nbsp; display: "none"&nbsp; &nbsp; }&nbsp; }});export default useStyles;回到您的组件上,只需导入此文件并将其附加到您希望隐藏其所有子input类型radio&的父级checkboximport useStyles from "./useStyles";function App() {&nbsp; const classes = useStyles();&nbsp; return (&nbsp; &nbsp; <div className={classes.hideCheckboxAndRadio}>&nbsp; &nbsp; &nbsp; <input type="text" />&nbsp; &nbsp; &nbsp; <input type="checkbox" />&nbsp; &nbsp; &nbsp; <input type="radio" />&nbsp; &nbsp; </div>&nbsp; );}
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript