我正在获取复选框值、选中状态、复选框标签、复选框课程 ID。使用爱可信方法的服务器.....现在我要发送回选中的复选框值,并使用爱可信方法...可以在其中任何一个帮助检查status..to后端... 。
我无法在响应控制台中执行和打印...请任何人帮忙
import React, { Component } from 'react';
import Row from 'react-bootstrap/Row';
import Col from 'react-bootstrap/Col';
import Button from 'react-bootstrap/Button'
import { List, ListItem } from '@material-ui/core';
import Checkbox from "@material-ui/core/Checkbox";
import FormGroup from "@material-ui/core/FormGroup";
import FormControlLabel from "@material-ui/core/FormControlLabel";
import Axios from 'axios'
class TwelvethCollegeCourses extends Component {
constructor(props) {
super(props)
this.state = {
checkboxes: [],
}
}
componentDidMount() {
Axios.get('http://127.0.0.1:8000/checkboxapi/checkbox/')
.then(response => {
this.setState({ checkboxes: response.data })
console.log(response.data)
})
.catch(error => {
console.log(error)
})
}
ChangeCheckBox = (e) => {
// onchange code checkbox
};
checkBoxSubmit = e => {
e.preventDefault();
Axios.post('http://127.0.0.1:8000/checkboxapi/user/')
.then(response => {
})
.catch(error => {
console.log(error)
})
};
render() {
const { checkboxes } = this.state
return (
<div>
<Container-Fluid>
<Row className="college-courses-row">
<Col sm={4} className="courses-box-college-courses-selected">
<div className="main-boxes">
<div className="course-collge-regis-index-boxes">
<div className="scrolling-data check-boxex-list">
<form>
<FormGroup aria-label="position" row>
<List className="courses-college-regis">
{checkboxes.map((checkbox, key) => (
<ListItem button key={key}>
<FormControlLabel
label={checkbox.CourseLabel}
type="checkbox"
id={checkbox.CourseId}
name="intermediatecourse"
value={checkbox.CourseValue}
control={<Checkbox color="primary" />}
onChange={this.ChangeCheckBox}
checked={checkbox.checked}
/>
</ListItem>
))}
</List>
</FormGroup>
</form>
</div>
</div>
</div>
</Col>
<Col sm={8}>
<div className="total-number-courses-save-box ">
<Button type="submit" onClick={this.checkBoxSubmit}>Save</Button>
</div>
</Col>
</Row>
</Container-Fluid>
</div >
)
}
}
export default TwelvethCollegeCourses;