这个TS问题如何解决?我的样式组件从文件中导出style.ts并在我的 React 组件的文件中使用index.tsx:
样式.ts:
import { styled, Theme } from '@mui/material/styles';
type CardProps = {
theme?: Theme;
selected: boolean;
};
const Card = styled('div', {
shouldForwardProp: (p) => !!p
})(({ theme, selected }: CardProps) => ({
display: 'flex',
flexDirection: 'column',
padding: theme?.spacing(2),
width: theme?.spacing(39.5),
boxShadow: theme?.shadows[2],
color: theme?.palette.grey[50],
borderRadius: theme?.spacing(0.5),
margin: `${theme?.spacing()} ${theme?.spacing(2)}`,
...(selected && {
background: theme?.palette.grey[100],
color: theme?.palette.getContrastText(theme?.palette.grey[100])
}),
...(!selected && {
cursor: 'pointer',
border: `1px solid #DEE4EA`
}),
'&:hover': {
...(!selected && { …Run Code Online (Sandbox Code Playgroud)