TypeError: Cannot read property 'length' of undefined
这就是编译器在我运行我的 React 应用程序时所说的。我需要做什么?
request = (start,end) => {
if(this.state.teams.length < 1){
axios.get(`${ URL }/teams`)
.then( response => {
this.setState({
teams:response.data
})
})
}
axios.get(`${ URL }/articles?_start=${start}&_end=${end}`)
.then( response => {
this.setState({
items:[...this.state.items,...response.data]
})
})
}
原文由 Kuba Kluzniak 发布,翻译遵循 CC BY-SA 4.0 许可协议
我建议首先检查道具是否未定义或为空,甚至是否已声明。
例如:-
并退回您的卡。