Javascript 无法读取未定义的属性形式

Javascript 无法读取未定义的属性形式,javascript,forms,reactjs,components,onload,Javascript,Forms,Reactjs,Components,Onload,我在react中有一个表单,不是redux表单,我希望表单自动提交。这是我的密码: class DummyForm extends React.Component { constructor(props) { super(props); this.state = { value: '' }; this.handleChange = this.handleChange.bind(this); this.onLoadEvent = this.onLoadEven

我在react中有一个表单,不是redux表单,我希望表单自动提交。这是我的密码:

class DummyForm extends React.Component {
  constructor(props) {
    super(props);
    this.state = { value: '' };

    this.handleChange = this.handleChange.bind(this);
    this.onLoadEvent = this.onLoadEvent.bind(this);
  }

  componentWillMount() {
    this.onLoadEvent();
  }

  onLoadEvent() {
    this.document.forms.threedfrom.submit();
  }

  handleChange(event) {
    this.setState({ value: event.target.value });
  }

  render() {
    return (
      <body>
      <form
        name="threedfrom"
        action={this.props.acsUrl}
        method="POST"
      >
          <textarea
            style={{ display: 'none' }}
            name="PaReq"
            value={this.props.pareqMessage}
          />
        <input
          type="hidden"
          name="MD"
          value={this.props.reservationCode}
        />
        <input type="submit" value="Submit" />
      </form>
      </body>
    );
  }
}
类DummyForm扩展了React.Component{
建造师(道具){
超级(道具);
this.state={value:''};
this.handleChange=this.handleChange.bind(this);
this.onLoadEvent=this.onLoadEvent.bind(this);
}
组件willmount(){
这个.onLoadEvent();
}
onLoadEvent(){
this.document.forms.3dfrom.submit();
}
手变(活动){
this.setState({value:event.target.value});
}
render(){
返回(
);
}
}

但是当安装组件时,我得到了错误uncaughttypeerror:cannotreadproperty'forms'的undefined表示文档未定义。这怎么可能?我错过了什么?非常感谢

此文档表示文档是此类的成员。您可以使用ref像以前一样进行提交

应该在哪里定义
this.document
呢?我认为
this.document
的意思很简单,就是
document
我想用formname threedfrom参与dom。我实施这一点的方式是错误的吗?还是应该用另一种方式实施这一点;为什么不直接调用直接提交时调用的函数呢?模拟提交事件主要用于编写测试用例。