React/JS/Es 6多重/二重循環配列/Object/Map
1739 ワード
1、データソース:
2、React多重循環
var module = [
{
"1": [
{
"name": " ",
"todayposts": "0",
"fid": "2"
},
{
"name": " ",
"todayposts": "0",
"fid": "58"
},
{
"name": " ",
"todayposts": "0",
"fid": "72"
},
{
"name": " ",
"todayposts": "0",
"fid": "73"
}
],
"59": [
{
"name": " ",
"todayposts": "0",
"fid": "60"
},
{
"name": " ",
"todayposts": "0",
"fid": "70"
},
{
"name": " ",
"todayposts": "0",
"fid": "42"
}
]
......
]
2、React多重循環
<select value={ state.form.fid } onChange={ this.setStateByKey.bind(this, 'fid') }>
<option value="0"> </option>
{
Object.keys(modules).map((key) => (
modules[key].map((item) => (
<option key={item.fid} value={item.fid}>{item.name}</option>
))
))
}
</select>