📌  相关文章
📜  获取输入反应的值 - Javascript代码示例

📅  最后修改于: 2022-03-11 15:01:57.751000             🧑  作者: Mango

代码示例3
class NameForm extends React.Component {
  constructor(props) {
    super(props);
    this.state = {value: ''};
    this.handleChange = this.handleChange.bind(this);
    this.handleSubmit = this.handleSubmit.bind(this);
  }

  handleChange(event) {    this.setState({value: event.target.value});  }
  handleSubmit(event) {
    alert('A name was submitted: ' + this.state.value);
    event.preventDefault();
  }

  render() {
    return (
      
); } }