課程
/前端開發(fā)
/React.JS
/React實戰(zhàn)--打造畫廊應用(上)
Main.js?7cd4:40 Uncaught TypeError: imageDatas.forEach is not a function。檢查了所有的代碼,評論的也試過了,不知道怎么回事
2016-06-28
源自:React實戰(zhàn)--打造畫廊應用(上) 3-2
正在回答
imageData并不是數(shù)組,而是對象,并不能使用Array原生方法forEach,可以這樣使用:
Array.prototype.forEach.call(imageData,(item,index)?=>?{ ?? ImageFigures.push(<ImageFigure?data={item}?key={index}/>); ?? });
楓葉咚咚咚
ES6的語法 不是forEach ?而是 ?for in 和for of
剛剛試著解決了一下:
加入
`let imageDatas = require('json!../data/imageDatas.json');`
·
imageDatas.forEach((item, index) => {
imgFigures.push(<ImgFigure data={item} key={index}/>);
});
Ancess
蘇莫離 提問者 回復 Ancess
qq_這都不是事_0 回復 蘇莫離 提問者
我也是
舉報
顛覆式前端UI開發(fā)框架 React,打造圖片畫廊實踐案講解
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學習伙伴
掃描二維碼關注慕課網(wǎng)微信公眾號
2017-05-07
imageData并不是數(shù)組,而是對象,并不能使用Array原生方法forEach,可以這樣使用:
2017-04-27
ES6的語法 不是forEach ?而是 ?for in 和for of
2016-07-01
剛剛試著解決了一下:
加入
`let imageDatas = require('json!../data/imageDatas.json');`
·
imageDatas.forEach((item, index) => {
imgFigures.push(<ImgFigure data={item} key={index}/>);
});
·
2016-07-01
我也是