您好,我在下面的应用程序中做出了反应,我必须管理一个表单来验证登录页面的权限,参数是电子邮件和密码,但是当我执行代码时,会显示以下错误,错误:第33行:表单”未定义react / jsx-no-undef
JavaScript代码:
import React, { Component } from 'react';
import { Button, FormGroup, FormControl, ControlLabel } from "react-bootstrap";
import logo from './logo.svg';
import './Home.css';
class Home extends Component {
constructor(props) {
super(props);
this.state = {
email: "",
password: ""
};
}
validateForm() {
return this.state.email.length > 0 && this.state.password.length > 0;
}
handleChange = event => {
this.setState({
[event.target.id]: event.target.value
});
}
handleSubmit = event => {
event.preventDefault();
}
render() {
return (
<div className="Login">
<Form onSubmit={this.handleSubmit}>
<Form.Group controlId="email" bsSize="large">
<Form.Control
autoFocus
type="email"
value={this.state.email}
onChange={this.handleChange}
/>
</Form.Group>
<Form.Group controlId="password" bsSize="large">
<Form.Control
value={this.state.password}
onChange={this.handleChange}
type="password"
/>
</Form.Group>
<Button
block
bsSize="large"
disabled={!this.validateForm()}
type="submit"
>
Login
</Button>
</Form>
</div>
);
}
}
export default Home;
答案 0 :(得分:3)
好像您忘记导入calloc()
,只需添加即可:
Form
答案 1 :(得分:0)
import { Form, Button, FormGroup, FormControl, ControlLabel } from "react-bootstrap";
上面为我做了