0
在下面的代碼中,我已經下載了一個JSON文件。 然後我把它的一個字典數組傳遞給downloadWebsiteData()。 在這個函數中談到以下錯誤:React-Native:Undefined不是一個對象,雖然前面有一個decleration
Undefined is not an object (evaluating 'web files.length')
這裏是我的代碼我使用:重要:webFiles是一個數組中!
downloadWebsiteData(webFiles) {
this.setState({amountOfAllWebsites: webFiles.length});
for(var ii = 0; ii < webFiles.length; ii++)
{
var urlToDownload = webFiles[ii].url;
fetch(urlToDownload, {method: "GET"}).then((responseData) => {
this.saveDataToLocalStorage(responseData, urlToDownload);
alert('Save: '+urlToDownload);
this.setState({actuallyLoadedWebsites: this.state.actuallyLoadedWebsites++});
this.downloadWebsiteData();
})
.done();
}
謝謝!這只是我的一個愚蠢的錯誤。謝謝您的回答! –