Dar*_* K. 3 reactjs material-ui
我正在使用 React Material-UI库,但不明白如何覆盖 FormHelperText 样式?
const { classes } = this.props
...
<TextField
name='username'
label='Username'
error={this.state.usernameInvalid}
helperText={this.state.usernameError}
classes={{
root: classes.textField,
FormHelperText: classes.helperText // <-- how to override by right way?
}}
onChange={this.handleInputChange}
/>
...
export default withStyles(styles)(SignInPopup)
Run Code Online (Sandbox Code Playgroud)
款式:
const styles = () => ({
textField: {
width: '100%'
},
helperText: {
position: 'absolute',
bottom: '-50%'
}
})
Run Code Online (Sandbox Code Playgroud)
我有这个错误:
Warning: Material-UI: the key `FormHelperText` provided to the classes property is not implemented in FormControl.
You can only override one of the following: root,marginNormal,marginDense,fullWidth
Run Code Online (Sandbox Code Playgroud)
解决方案在这里:
<TextField
name='username'
label='Username'
className={classes.textField}
error={this.state.usernameInvalid}
helperText={this.state.usernameError}
FormHelperTextProps={{ classes: { root: classes.helperText } }} // <- smth like that
onChange={this.handleInputChange}
/>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6600 次 |
| 最近记录: |