7
這是我目前想要在我的組件中執行的操作。每當我路由到不同的組件時,我想刪除或銷燬我的localStorage內容。我想達到這個目的,以避免localStorage變量存儲以前的值,即使是新的值也會進來。我是否在正確的道路上?如何銷燬localStorage項目 - 角
遊戲組件
export class Game implements OnDestroy{
constructor(){
this.currentGame = JSON.parse(localStorage.getItem('currentGame'));
}
ngOnDestroy(){
this.currentGame = null;
}
}
從localStorage的用[刪除項目的可能的複製清除整個localStorage的AngularJS(http://stackoverflow.com/questions/2632396 1/removed-items-from-localstorage-with-angularjs) – Liam
[從localstorage javascript中刪除值]的可能重複(http://stackoverflow.com/questions/14864256/remove-value-from-localstorage-javascript) –