19 lines
504 B
JavaScript
19 lines
504 B
JavaScript
let databaseName = 'cellsys';
|
|
let version = 1;
|
|
let db;
|
|
let request = window.indexedDB.open(databaseName, version);
|
|
request.onerror = function (error) {
|
|
console.log('IndexDB打开失败', error);
|
|
};
|
|
request.onsuccess = function (res) {
|
|
console.log('IndexDB打开成功', res);
|
|
db = res.target.result;
|
|
};
|
|
|
|
function addLog() {
|
|
const transaction = db.transaction(['myObjectStore'], 'readwrite');
|
|
const objectStore = transaction.objectStore('myObjectStore');
|
|
|
|
objectStore.add(data);
|
|
}
|