【发布时间】:2016-11-26 04:09:10
【问题描述】:
在以下代码中,我下载了一个 JSON 文件。 之后,我将它的字典数组传递给 downloadWebsiteData()。 在这个函数中,它出现以下错误:
未定义不是一个对象(评估'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();
}
【问题讨论】:
标签: javascript ios error-handling download react-native