0
這是我一直在努力的代碼。由於某種原因,它返回給我以下錯誤:PouchDB更新文檔:DataCloneError
Uncaught DataCloneError: Failed to execute 'put' on 'IDBObjectStore': An object could not be cloned.
甚至在我嘗試使用upsert插件之前就發生了這種情況。
db.get(id).then(doc => {
console.log(doc);
return db.upsert(id, doc => {
doc.exp_date = moment(doc.exp_date).add(parseInt(document.getElementById('ext_date').value), 'years');
return doc;
}).then(res => console.log(res)).catch(err => console.log(err));
})
我可以知道這個錯誤的分辨率嗎?
通過
add()
返回的東西,可以被克隆,如日期,數量等對象轉換我採取了一些不同的方式解決了這個問題。我在PouchDB問題上得到了答案。我簡單地使用了'moment(...)。add(...)._ d' –