我正在尝试使用循环将至少 10 行写入文件以使用 PhoneGap 在文件中附加多行,但每次我在下面运行此代码时,只能将 1 行作为换行符添加到文件中。但是在 10 次迭代中没有打印 10 行。请建议我如何使用 phoneGap javascript 纠正我的问题。
function gotFileWriter(writer) {
for (var z = 0; z<= 10; z++) {
console.log("normal write success");
writer.onwrite = function(evt) {
console.log("write success");
};
writer.onwriteend = function(evt) {
console.log("write end");
}
writer.seek(writer.length);
writer.write("id,updated,created,fname,lname,company,tags,type,label,value,source,sourceid\r\n");
writer.abort(); // I tried even commenting
}
}