1 回答

TA貢獻(xiàn)1780條經(jīng)驗 獲得超1個贊
我不知道你為什么要這樣做希望你有充分的理由但是你應(yīng)該這樣做
表搜索.jsx
import React from "react";
export default class TableSearch extends React.Component {
render() {
const { value, onChange, onSearch } = this.props;
return (
<div className="tableSearch">
<input type="text" className="searchInput" onChange={onChange} value={value} placeholder="Search by flight" />
<button className="buttonSearch" onClick={() => onSearch(value)}>Search</button>
</div>
);
}
};
表格數(shù)據(jù).jsx
import React from "react";
export default class TableData extends React.Component {
render() {
const { data } = this.props;
return (
<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 => {
const dt = new Date(item.actual);
const mins = dt.getMinutes();
return (
<tr key={item.ID}>
<td>{item.term}</td>
<td>{item.gateNo}</td>
<td>{`${dt.getHours()}:${mins < 10 ? '0' : ''}${mins}`}</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>
);
}
}
添加回答
舉報