簡體   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