【发布时间】:2022-01-26 20:25:54
【问题描述】:
我在一个小型 React 应用程序上遇到以下错误。
我用"@material-ui/core": "4.11.3"
我有一个Text.tsx 组件,它的样式在Text.styles.tsx 中。我使用makeStyles 函数。
text.styles.tsx
import { makeStyles, Theme } from '@material-ui/core';
interface StyleProps {
marginRight: number;
marginLeft: number;
}
const useStyles = makeStyles((theme: Theme) => {
return {
root: {
marginRight: (props: StyleProps) => theme.spacing(props.marginRight),
marginLeft: (props: StyleProps) => theme.spacing(props.marginLeft),
},
weightBold: {
fontWeight: theme.typography.fontWeightBold,
},
weightSemiBold: {
fontWeight: theme.typography.fontWeightMedium,
},
weightRegular: {
fontWeight: theme.typography.fontWeightRegular,
},
colorWhite: {
color: theme.palette.background.default,
},
underlinedText: {
textDecoration: 'underline',
},
notUnderlinedText: {
textDecoration: 'none',
},
};
});
export default useStyles;
【问题讨论】: