//过滤一个结果的空记录添加,过滤空搜索  默认保存10条记录,自己可修改
function setHistoryItems(keyword) {
    keyword = keyword.replace("/^\s+|\s+$/g","");
    let { historyIndexSearchItems } = localStorage;
    if (historyIndexSearchItems === undefined) {  
          localStorage.historyIndexSearchItems = keyword;  
    } else {  
          const onlyItem = historyIndexSearchItems.split('|').filter(e => e != keyword);  
          if (onlyItem.length > 0){
              historyIndexSearchItems = keyword + '|' + onlyItem.slice(0,9).join('|');
          }  
          localStorage.historyIndexSearchItems = historyIndexSearchItems;
    }  
}
function clearHistory() {
    localStorage.removeItem('historyIndexSearchItems');   
}

 

相关文章:

  • 2021-09-08
  • 2021-11-17
  • 2021-11-23
  • 2021-12-24
  • 2021-08-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-31
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-24
相关资源
相似解决方案