goddess
侠客
侠客
  • 最后登录2021-12-20
  • 发帖数18
阅读:4915回复:0

[javascript]TypeError: Cannot read property 'map' of undefined

楼主#
更多 发布于:2019-12-03 15:57
定位bug:数组遍历map导致的
{(arr).map(i => (    <span>{i}</span>))}
只要在要循环的数组后面(我的是data)加一个|| []就可以了
{(arr || []).map(i => (    <span>{i}</span>))}

[goddess于2019-12-03 17:42编辑了帖子]
游客


返回顶部

公众号

公众号