我試圖實現上傳文件和文件夾的功能。我在chrome中刪除了一些文件和文件夾,然後我得到了dataTransferItemList類型的條目列表,然後我想對列表中的每個條目執行一些操作。我得到一個webkitGetAsEntry函數的條目,當我嘗試調用FileEntry對象的文件函數dataTransferItemList變爲空時。FileEntry.file方法使dataTransferItemList爲空
_processEntries: function() {
//this._entries list of entries of type dataTransferItemList
var entry = this._getNetxFileEntry(this._entries);
if (!isNullOrUndefined(entry)) {
if (entry.webkitGetAsEntry) {
entry = entry.webkitGetAsEntry();
} else {
//TODO: code for other browsers without getAsEntry implementation
}
if (entry.isFile) {
this._readAsFileEntry(entry);
}
else if (entry.isDirectory) {
this._readAsDirectoryEntry(entry);
}
}
},
_readAsFileEntry: function (fileEntry) {
fileEntry.file($.proxy(this._onFileSuccessfullyRead, this));
},
_onFileSuccessfullyRead: function (file) {
//Here this._entries becomes empty so i can't read next entry
},
爲什麼會發生這種情況,我該如何處理這種情況下的所有內容? 感謝您的幫助。