我正在使用 react 我想在 UI 上显示一些动态内容,但由于我是新手而无法循环数据,所以发现这很难做到
state={
dashboardManpowerCount:{
"CurrentMonth": {
"Total No of employes": 25,
"Ariving": 10,
"Exited": 8
},
"PreviousMonth": {
"Total No of employes": 25,
"Ariving": 10,
"Exited": 8
}
}
}
class currAndprevMonthcCounts extends Component {
render(){
const {dashboardManpowerCount} = this.state
return(
<div>
<div className="col-6 col-sm-6 col-md-6 col-lg-3 col-xl-3">
<div className="row">
<div className="col-12 col-sm-12 col-md-6 col-lg-5 col-xl-5">
<h6>Previous Month</h6>
<h2>395</h2>
</div>
<div className="col-12 col-sm-12 col-md-6 col-lg-7 col-xl-7">
<span className="badge badge-pill badge-secondary mt-2"
>+7 Ariving</span>
<br></br>
<span className="badge badge-pill badge-secondary mt-3">-3 Exiting</span>
</div>
</div>
</div>
<div className="col-6 col-sm-6 col-md-6 col-lg-3 col-xl-3">
<div className="row">
<div className="col-12 col-sm-12 col-md-6 col-lg-5 col-xl-5">
<h6>Previous Month</h6>
<h2>395</h2>
</div>
<div className="col-12 col-sm-12 col-md-6 col-lg-7 col-xl-7">
<span className="badge badge-pill badge-secondary mt-2">+5 Ariving</span>
<br></br>
<span className="badge badge-pill badge-secondary mt-3">-3 Exiting</span>
</div>
</div>
</div>
</div>
)
}
}
有两个选项当前月份数据和上个月数据我想循环访问对象并代替我的 jsx 中的静态内容呈现
这就是
子衿沉夜
相关分类