// 切换城市
changeCity({label,value}){
if(HOUSE_CITY.indexOf(label)>-1){
localStorage.setItem('hkzf_city',JSON.stringify({label,value}))
this.props.history.go(-1)
}else{
Toast.info('暂无该城市房源', 1);
}
}
// 渲染每一行数据的渲染函数 函数的返回值就是渲染在页面的每一行内容
rowRenderer=({
key, // Unique key within array of rows
index, // Index of row within collection
isScrolling, // The List is currently being scrolled
isVisible, // This row is visible within the List (eg it is not an overscanned row)
style, // Style object to be applied to row (to position it)
})=> {
const { cityIndex,cityList } = this.state
const letter = cityIndex[index]
return (
<div key={key} style={style} className="city" >
<div className="title">{formatCityIndex(letter)}</div>
{
cityList[letter].map((item=><div className="name" key={item.value} onClick={()=>this.changeCity(item)}>{item.label}</div>))
}
</div>
)
}
城市列表(3)点击切换定位城市
最新推荐文章于 2020-04-08 11:08:32 发布