![](/img/trans.png)
[英]trying to delete a specific item from the localStorage array in Javascript
[英]Delete only specific item from localstorage using javascript?
即使在客戶端從我的網站注銷后,我也需要存儲Storageselectedclient以便當我們再次登錄時,最后選擇的客戶端將顯示出來,但它不起作用,我的整個項目也在Angular 7 中。
這是我的工作代碼,其中也有空閑注銷功能
var IDLE_TIMEOUT = 10; //seconds
var _idleSecondsCounter = 0;
document.onclick = function () {
_idleSecondsCounter = 0;
};
document.onmousemove = function () {
_idleSecondsCounter = 0;
};
document.onkeypress = function () {
_idleSecondsCounter = 0;
};
$(window).on('hashchange', function(e){
_idleSecondsCounter = 0;
});
window.setInterval(CheckIdleTime, 1000);
function CheckIdleTime() {
_idleSecondsCounter++;
var oPanel = document.getElementById("SecondsUntilExpire");
if (oPanel)
oPanel.innerHTML = (IDLE_TIMEOUT - _idleSecondsCounter) + "";
if (_idleSecondsCounter >= IDLE_TIMEOUT) {
localStorage.clear();
window.location.replace(location.origin);
}
}
您可以使用removeItem()刪除數據
localStorage.removeItem('key')
使用clear()將清除所有本地存儲。
localStorage.clear()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.