所以我进行了研究并获得了此链接。 Material UI change Input's active color
但仍然出现错误。 (0 , _styles2.createMuiTheme) is not a function
https://codesandbox.io/s/m7z2l1j09y
const theme = createMuiTheme({
palette: {
secondary: {
main: "#E33E7F"
},
formControl: {
color: "black"
}
}
});
<MuiThemeProvider theme={theme}>
<FormControl component="fieldset" className={classes.formControl}>
<FormLabel component="legend">Gender</FormLabel>
<RadioGroup
aria-label="Gender"
name="gender1"
className={classes.group}
value={this.state.value}
onChange={this.handleChange}
>
{radioValues.map(radio => {
return (
<FormControlLabel
value={radio.value}
control={<Radio />}
label={radio.label}
/>
);
})}
</RadioGroup>
{checkBoxvalues.map((check, index) => {
return (
<FormControlLabel
key={check.value}
control={
<Checkbox
checked={check.checked}
onChange={this.handleCheckBoxChange(check.value, index)}
value={check.value}
/>
}
label={check.label}
/>
);
})}
</FormControl>
</MuiThemeProvider>
答案 0 :(得分:1)
您的错误是由于import
不正确造成的。
代替
import { MuiThemeProvider, createMuiTheme } from "material-ui/styles";
应该是
import { MuiThemeProvider, createMuiTheme } from "@material-ui/core/styles";
我还添加了在复选框上指定color
属性。
这是您的沙盒的有效版本:https://codesandbox.io/s/w68nm77o0k