我正在使用 indexeddb 来存储 chrome-extension 的用户详细信息。我想清除 indexeddb 但清除方法不起作用。当我点击注销时没有任何反应 我不明白为什么
这是我到目前为止尝试过的。 我知道我也可以使用 delete 但是为了我的功能我需要使用 clear 方法
const logoutButton = document.getElementById('logout-btn');
logoutButton.addEventListener('click', function () {
const transaction = db.transaction('users', 'readwrite');
const objectStore = transaction.objectStore('users');
const clearRequest = objectStore.clear();
clearRequest.onsuccess = function () {
message.style.display = 'none';
form.style.display = 'block';
form.reset();
};
clearRequest.onerror = function () {
console.error('Error clearing user data from IndexDB');
};
});