我有一些 API。我从这个 API 中获取数据并将其作为列表显示在页面上。但是在时间字段中,我只想在我的页面上显示部分信息。
现在数据显示如下:
但我需要它是这样的(只有几小时和几分钟):
如何在我的情况下实施它?请不要链接,我需要专门针对我的情况的帮助。
这是一个显示表格列表的组件(TableData.js): import React from "react";
export default ({ data }) => (
<div className="tableContainer">
<table className="table">
<thead>
<tr>
<th>Terminal</th>
<th>Gate</th>
<th>Time</th>
<th>Destination</th>
<th>Airline</th>
<th>Flight</th>
<th>Status</th>
</tr>
</thead>
<tbody>
{data.map(item => (
<tr key={item.ID}>
<td>{item.term}</td>
<td>{item.gateNo}</td>
<td>{item.actual}</td>
<td>
{item["airportToID.city_en"]
? item["airportToID.city_en"]
: item["airportFromID.city_en"]}
</td>
<td>{item.airline.en.name}</td>
<td>{item["planeTypeID.code"]}</td>
<td>{item.status}</td>
</tr>
))}
</tbody>
</table>
</div>
);
飞机.js(减速机):
import { searchFilter } from "../components/app";
export function reducer(state = {}, action) {
switch (action.type) {
case "SET_SHIFT":
return Object.assign({}, state, {
shift: action.shift
});
case "SET_SEARCH":
return Object.assign({}, state, {
search: action.search.toLowerCase()
});
case "RUN_FILTER":
var newData = state.data[action.shift || state.shift].filter(x => {
return (
x["planeTypeID.code"].toLowerCase().includes(action.search || state.search)
);
});
return Object.assign({}, state, {
shift: action.shift || state.shift,
search: action.search || state.search,
filteredData: searchFilter(state.search, newData)
});
慕容森
慕姐8265434
一只甜甜圈
相关分类