Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript react.js foreach变量错误_Javascript_Reactjs - Fatal编程技术网

Javascript react.js foreach变量错误

Javascript react.js foreach变量错误,javascript,reactjs,Javascript,Reactjs,为什么控制台中没有定义我获取的记录?它也不会打印任何值 this.props.records.forEach(function(record){ numbers.push( <tr key={record.id} > <td>{record.title}</td> </tr>) }) 数组可能包含一些未定义的值(例如,[{id:1},未定义,{id:2}

为什么控制台中没有定义我获取的记录?它也不会打印任何值

this.props.records.forEach(function(record){ 
      numbers.push(        
        <tr key={record.id} >
          <td>{record.title}</td>
        </tr>)
      })

数组可能包含一些未定义的值(例如,
[{id:1},未定义,{id:2}]


您能复制/粘贴原始错误吗?在哪一行出现了错误?在控制台中用错误更新了问题。在前面添加
console.log(records)
,查看是否有未定义的错误
Uncaught ReferenceError: record is not definedReact.createClass.onChange @ Inline JSX script:137React.createClass.changeHandler @ Inline JSX script:82ReactClass.createClass._handleChange @ react-with-addons.js:9067executeDispatch @ react-with-addons.js:3307forEachEventDispatch @ react-with-addons.js:3295executeDispatchesInOrder @ react-with-addons.js:3316executeDispatchesAndRelease @ react-with-addons.js:2689forEachAccumulated @ react-with-addons.js:19368EventPluginHub.processEventQueue @ react-with-addons.js:2896runEventQueueInBatch @ react-with-addons.js:11161ReactEventEmitterMixin.handleTopLevel @ react-with-addons.js:11187handleTopLevelImpl @ react-with-addons.js:11273Mixin.perform @ react-with-addons.js:18340ReactDefaultBatchingStrategy.batchedUpdates @ react-with-addons.js:9613batchedUpdates @ react-with-addons.js:16573ReactEventListener.dispatchEvent @ react-with-addons.js:11367
console.log(this.props.records);
// or set a debugger statement to inspect the state