irpas技术客

.map() is not a function【js报错】_lilly呀

大大的周 2692

下面的代码报错TpyeError:data.map is not a function.

let nameList = data.map(item => item.name); 原因1:data不是数组; 解决方法:将data转换成数组 let data = Array.from(data); map不能遍历HTMLCollection类型的数据,必须先将HTMLCollection转换成array。接着使用for循环,发现能正常运行。

参考博客:记录React JS TypeError: data.map is not a function??https://blog.csdn.net/weixin_44371012/article/details/89716413

? ? ? ? ? ? ? ? ? .map() is not a function【js报错】?https://·/jaycethanks/p/13491512.html


1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,会注明原创字样,如未注明都非原创,如有侵权请联系删除!;3.作者投稿可能会经我们编辑修改或补充;4.本站不提供任何储存功能只提供收集或者投稿人的网盘链接。

标签: #map #is #not #a #functionjs报错