下面的代码片段显示了alert("Added"),但没有向indexDB中添加任何内容。我的indexDB中有一个条目,但我无法添加更多条目。
var transaction = db.transaction("movies", "readwrite")
.objectStore("movies") // keypath is also there :{keyPath: "imdbID"}
.add(movieDetailObject);
transaction.onsuccess = function(event) {
alert("Added");
};
transaction.onerror = function(event) {
alert("Error");
} 如何添加更多值为keypath和object的条目?
发布于 2017-05-13 00:30:31
没有周围的代码很难判断,但是每个条目的keyPath可能是相同的。
为了更好地实践,您还应该监听可以在.add(movieDetailObject)返回的IDBRequest上触发的事件,以查看是否触发了onsuccess或onerror。
https://stackoverflow.com/questions/43921244
复制相似问题