繁体   English   中英

如何使用表格形式的GET API获取数据

[英]How Can i Get data using GET API In Tabular Form

我想使用表格以表格形式显示我的投诉数据。 我试过使用列表它的工作。 我没有如何使用表格以表格形式显示数据。 当我尝试过控制台日志和邮递员时,它将显示数据库中包含的数据。 我想以表格形式获取数据。 请帮我解决。

 import React,{Component} from 'react'; import {Table} from 'react-bootstrap'; import axios from 'axios'; export default class Display extends React.Component{ constructor(props) { super(props); this.componentDidMount(); this.state = { complaints: [] }; } componentDidMount() { axios.get(`http://localhost:80/get/complaints`) .then(res => { // console.log(res.data) // const complaints = res; this.setState({ complaints: res.data }); }) } render() { console.log(this.state.complaints) return ( // <ul> // {this.state.complaints.map(complaints => ( // <li key={complaints.id}>{complaints.Regdno}</li> // ))} // </ul> <Table responsive> <thead> <tr > <th>Regd_no</th> <th>Year Of Study</th> <th>Location</th> <th>Department</th> <th> Disciplinary Issue</th> </tr> </thead> </Table> ) } } 

可以使用固定数据表2通过API响应以表格形式显示数据。 它提供了一个动态表,其中行数作为JSON对象的索引。

有关更多信息,您可以访问: http : //schrodinger.github.io/fixed-data-table-2/example-object-data.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM