我有以下代码:
    constructor(props) {
        super(props);
        this.state = {
            search: "",
            value: "",
            username:'',
            email:'',
            password: '',
        };
        this.onChange = this.onChange.bind(this);
        this.onSubmit = this.onSubmit.bind(this);
    }
...
...
    onChange(e) {
        this.setState(
            {[e.target.name]: e.target.value})
    }
...
...
<input type="password" placeholder="Password"
onChange={e => this.onChange(e)}
value={ this.state.password }
                                                />
但是我无法在密码字段中输入。如果删除该value={ this.state.password }零件,则可以在该字段中键入内容,但是当更改此字段时,状态似乎没有更新。
问题是什么?
您忘记在密码字段中输入名称。它应该是
<input 
 type="password" 
 placeholder="Password"
 name="password"
 onChange={e => this.onChange(e)}
 value={ this.state.password }
/>
| 归档时间: | 
 | 
| 查看次数: | 46 次 | 
| 最近记录: |