以下代码存在错误。
我必须在JavaScript中加载对象并在JavaScript中创建模型。为此,我使用下面的代码。执行包含
错误:
期望分配或函数调用,而看到一个表达式no-unused-expressions
代码:
import * as React from 'react';
import { Button, Form, FormGroup, FormControl, ControlLabel } from "react-bootstrap";
import logo from './logo.svg';
import { HeadProvider, Title, Link, Meta } from 'react-head';
import * as Router from 'react-router';
import './Home.css';
import RegisterPage from "./Register.js"; //L'oggetto RegisterPage contiene l'oggetto Register
<Router.Route path="./Register.js" component={RegisterPage.Register} />
class Home extends React.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 (
<React.Fragment>
<HeadProvider>
<Meta charset="UTF-8"/>
<Meta name="viewport" content="width=device-width, initial-scale=1"/>
<Link rel="icon" type="image/png" href="images/icons/favicon.ico"/>
<Link rel="stylesheet" type="text/css"
href="vendor/bootstrap/css/bootstrap.min.css"/>
<Link rel="stylesheet" type="text/css"
href="fonts/font-awesome-4.7.0/css/font-awesome.min.css"/>
<Link rel="stylesheet" type="text/css"
href="fonts/iconic/css/material-design-iconic-font.min.css"/>
<Link rel="stylesheet" type="text/css" href="vendor/animate/animate.css"/>
<Link rel="stylesheet" type="text/css"
href="vendor/css-hamburgers/hamburgers.min.css"/>
<Link rel="stylesheet" type="text/css"
href="vendor/animsition/css/animsition.min.css"/>
<Link rel="stylesheet" type="text/css" href="vendor/select2/select2.min.css"/>
<Link rel="stylesheet" type="text/css"
href="vendor/daterangepicker/daterangepicker.css"/>
<Link rel="stylesheet" type="text/css" href="css/util.css"/>
<Link rel="stylesheet" type="text/css" href="css/main.css"/>
</HeadProvider>
<div className="Login">
<Form onSubmit={this.handleSubmit}>
<Form.Group controlId="email" bsSize="large">
<label> Email: </label>
<Form.Control
autoFocus
type="email"
value={this.state.email}
onChange={this.handleChange}
/>
</Form.Group>
<br></br>
<Form.Group controlId="password" bsSize="large">
<label> Password: </label>
<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>
</React.Fragment>
);
}
}
export default Home;