React脚手架实现遍历,要加key
对应代码:
{
this.props.users.map((userObj) => {
return (
<div key={userObj.id} className="card">
<a rel='noreferrer' href={userObj.html_url} target='_blank'>
<img src={userObj.avatar_url} style={{width:'100px'}} alt="head_portrait"/>
</a>
<p className='card-text'>{userObj.login}</p>
</div>
)
)
}
These are bilibili尚硅谷React学习视频的 学习笔记~