由于某种原因,回调没有被调用?有任何想法吗? 警报1和2被调用,但不是3或4 .. 控制台中没有错误,已安装的cordova文件插件和我的index.html包括cordova.js和cordova_plugins.js
感谢您的帮助, NIK
alert(1);
var data = "test 123";
var fileName = "data.json";
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
alert(2);
function gotFS(fileSystem) {
alert(3);
fileSystem.root.getFile(fileName, {
create: true,
exclusive: false
}, gotFileEntry, fail);
}
function gotFileEntry(fileEntry) {
fileEntry.createWriter(gotFileWriter, fail);
}
function gotFileWriter(writer) {
writer.onwriteend = function(evt) {
console.log("Write to file successful!");
};
writer.write(data);
}
function fail(error) {
alert(4);
console.log(error.code);
}