[英]material ui textfield cannot editable
I use material UI and a field text of type TextField. 我使用材料UI和TextField类型的字段文本。 But when I was seized in my field email, the seizure does not appear to the screen and the value does not change in the email field.It always remains the same value.
但是当我在现场电子邮件中被扣押时,扣押不会出现在屏幕上,并且电子邮件字段中的值也不会更改,它始终保持相同的值。
Handle change is not working. 句柄更改不起作用。 the value is not passing to the
handleChanges
remains the same value 该值未传递给
handleChanges
保持相同的值
<TextField fullWidth={true}
className={classes.margin}
label={<FormattedMessage id="LoginTemplate.email" defaultMessage="Email" />}
id="email"
ref="email"
name="eamil"
type="email"
value={authentification.email}
onChange={this.handleChange}
InputProps={{
endAdornment: (
<InputAdornment position="end">
<Email className={classes.inputIconsColor} />
</InputAdornment>
),
}}
/>
Here is the code. 这是代码。 Correct me What is the issue in that Thanks in Advance.
纠正我,“预先感谢”中的问题是什么。
In order to make the value change, you need to change a state (in the screen or external). 为了更改值,您需要更改状态(在屏幕或外部)。
For instance (with bad performance but just to explain): add to your cunstrunctor if exists: 例如(性能不好,但仅作解释):如果存在则添加到您的cunstrunctor中:
constructor(props) {
super(props);
this.state = {
emailInputText: undefined //or empty string
}
}
Then change TextField
component value
and onChange
props to: 然后将
TextField
组件value
和onChange
道具更改为:
value={this.state.emailInputText}
onChange={(text) => this.setState({emailInputText: text})}
I will consider to remove the
ref='email'
.我将考虑删除
ref='email'
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.