onActivated(() => { this.searchRecordList.value = localStorage.getItem('searchRecord') ? JSON.parse(localStorage.getItem('searchRecord') as string) : [];this.getList(); window.addEventListener('storage', this.getItem); }); onDeactivated(() => { window.removeEventListener('storage', this.getItem); });
protected getItem = () => { this.searchRecordList.value = localStorage.getItem('searchRecord') ? JSON.parse(localStorage.getItem('searchRecord') as string) : []; };
标签:缓存,searchRecordList,storage,searchRecord,localStorage,getItem,监听,页面 From: https://www.cnblogs.com/lopb/p/18168118