【问题标题】:An interface can only extend an object type or intersection of object types with statically known members接口只能扩展对象类型或对象类型与静态已知成员的交集
【发布时间】:2023-01-13 15:50:56
【问题描述】:

我试图在这里使用 TextFieldProps,但没有任何效果。有人知道如何处理这个问题吗?如何正确使用 TextFieldProps?感谢帮助。

import TextField, { TextFieldProps } from '@mui/material/TextField';
import { colorThemes } from '../../variables/style.variables';

interface BDBTextFieldProps extends TextFieldProps {
  customColor?: string;
}

export const BDBTextField = ({
  customColor = colorThemes.primary,
  ...props
}: BDBTextFieldProps) => {
  return (
    <TextField
      {...props}
      sx={{
        '& label.Mui-focused': {
          color: customColor,
        },
        '& .MuiOutlinedInput-root': {
          '&.Mui-focused fieldset': {
            borderColor: customColor,
          },
        },
      }}
    />
  );
};

【问题讨论】:

    标签: reactjs typescript material-ui


    【解决方案1】:

    使用接口不允许您扩展具有静态未知成员的对象。尝试改用类型。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-27
      • 1970-01-01
      • 1970-01-01
      • 2017-08-18
      相关资源
      最近更新 更多