1: 遍歷數(shù)據(jù)出錯(cuò)const Dashboard = React.createClass({ getInitialState:function(){ return{ names:[] } }, componentDidMount:function(){ var test={ "list": [ { "id": 1 }, { "id": 7 }, ] } this.setState({names:test}) }, render() { return ( <div> { this.state.names.map(function (list) { return <div>Hello, {list.id}!</div> }) } </div> ) }})數(shù)據(jù)取不到,this.state.names.map is not a function報(bào)這個(gè)錯(cuò) 是數(shù)據(jù)類(lèi)型有問(wèn)題么,沒(méi)找出具體問(wèn)題?
React this.state.names.map is not a function
月關(guān)寶盒
2018-08-10 10:10:10