我想寫至少10行文件,使用循環在文件中使用PhoneGap追加多行,但每次我在下面運行此代碼時,能夠將1行添加到文件中作爲換行符。但10行不打印10行。請建議我如何使用phoneGap javascript糾正我的問題。無法在Javascript中使用循環寫入10行文件(PhoneGap)
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
}
}