React 列表渲染
列表渲染用的最多的是使用高阶函数Map
例如
this.state={
lists:['asd','ad','adf','dfg','rtf']
}
<ul> { this.state.lists.map((item)=>{ return <li>{item}</li> }) } </ul>
问题:列表显示数值大于等于50的数据
可以使用filter过滤后再通过map展示数据
<ul> { this.state.numbers.filter((item,idnex,arr)=>{ return item>=50 }).map(item=>{ return <li>{item}</li> }) } </ul>
人,一定不能懒,懒习惯了,稍微努力一下便以为是在拼命。

浙公网安备 33010602011771号