我的返回 json 文件如下所示:
var data = [{"col1":"value1","col2":"value1","col3":"value1"},{"col1":"value2","col2":"value2","col3":"value2"},{"col1":"value3","col2":"value3","col3":"value3"}];
没有 JSON.stringify 数据看起来像这样:
[对象对象],[对象对象],[对象对象]
但有了它,result.length 不是 5,而是字符串的字符总数,这样我就不能循环了
var result = JSON.stringify(data);
for(i=0; i<result.length; i++){
var transaction = db.transaction([STORE], IDBTransaction.READ_WRITE);
var put = transaction.objectStore(STORE).put(result);
};