var newPoiTypeList = data.response;
newPoiTypeList .forEach(function (val, idx, arr) {
if (val.type_name == '公交站') {
val.icon = ""
}
})
this.setState({
poiTypeList: newPoiTypeList,
})
// render
{this.state.poiTypeList.map((i, index) => {
return (
<li className="poi_icon" onClick={this.poiTypeOn.bind(this, index, i.type_id, i.type_name)} >
<p ><i className="iconfont" dangerouslySetInnerHTML={{ __html: i.icon }}></i></p>
<p>{i.type_name}</p>
</li>
)
})}
react循环数组,根据数据内容,添加对象属性,动态设置icon
最新推荐文章于 2023-07-31 08:12:22 发布