【发布时间】:2020-05-13 07:00:47
【问题描述】:
我在 React js 中遇到问题,我想从 api 数据中获取员工 breaks 的价值,
API 数据
staff: [
{
"id": "1",
"full_name": "Barbershop",
"breaks": [
{
"starttime": "10:00:00",
"endtime": "12:00:00"
},
{
"starttime": "12:30:00",
"endtime": "1:00:00"
}
]
}
]
反应组件数据
const getRowData = () => {
return (
this.state.staff &&
this.state.staff.length &&
this.state.staff.map(({ full_name,breaks }) => (
<span className="more-space" key={full_name}>
{id}
{full_name}
{breaks.start_date} //this is not working
{breaks.end_date} //just show start_date or end_date
</span>
))
);
};
我应该对我的代码进行哪些更改?谁能帮帮我?
【问题讨论】:
标签: javascript arrays reactjs object