Getting a TypeMismatchError: Value is not Object
in den folgenden CodesTizen Web Application Wearable: TypeMismatchError
var fileHandler = {
storages:null,
documentsDIR:null,
newFile:null,
dirName:"documents",
fileName:"test.csv",
init: function init(){
//tizen.filesystem.listStorages(this.checkCorruptedRemovableDrives);documents
tizen.filesystem.resolve(this.dirName, this.resolveSuccessCB,this.resolveErrorCB,"rw");
},
resolveSuccessCB: function resolveSuccessCB(result){
this.documentsDir = result;
//this.newFile = documentsDir.createFile(this.fileName);
// Error Here - TypeMismatchError: Value is not Object
result.listFiles(this.listFilesSuccessCB);
console.log("All Good in "+this.documentsDir);
},
resolveErrorCB: function resolveErrorCB(error){
console.log("Unable to access "+this.dirName+". Error:"+error.message);
},
listFilesSuccessCB: function listFilesSuccessCB(files){
for (var i = 0; i < files.length; i++){
/* Display the file name and URI */
console.log("File name is " + files[i].name + ", URI is " + files[i].toURI());
}
},
onStorage: function onStorage(storage){
console.log("Storage found:" + storage.label);
},
checkCorruptedRemovableDrives: function checkCorruptedRemovableDrives(storages){
this.storages = storages;
for (var i = 0; i < storages.length; i++)
{
if (storages[i].type != "EXTERNAL"){
continue;
}
if (storages[i].state == "UNMOUNTABLE"){
console.log("External drive " + storages[i].label + " is corrupted.");
} else {
console.log(" Storage = " + storages[i].label);
// Error here - TypeMismatchError: Value is not Object
tizen.filesystem.getStorage(storages[i].label, this.onStorage);
}
}
}
}; Der Fehler tritt an zwei Stellen auf, die als Fehler in den Codes markiert sind.
In tizen.filesystem.getStorage(storages[i].label, this.onStorage);
ist der Datentyp des ersten Arguments DOMString und storages[i].label
ist auch vom Typ DOMString. In result.listFiles(this.listFilesSuccessCB);
erwartet eine Callback-Funktion.
Die meisten Codes wurden kopiert eingefügt von Tizen FileSystem Guide, aber immer noch nicht funktioniert.
Bitte helfen. Danke im Voraus!! Auch wo finde ich das Verzeichnis "Dokumente", wenn ich das Dateisystem meines tragbaren Geräts durchsuche.
Bitte mehr Details Code geben. –