function getTime(type,current) { //获取当天日期前一天 let time = new Date(); let date = time.getDate()-current||0; return type + date;};let str = this.getTime('preferential');返回 'preferential23' if (!localStorage.getItem(str)) { //检查今天的localStorage在不在,不再就存,读取也是一样; localStorage.setItem(str,'122')}删除昨天的数据的话let str = this.getTime('preferential',1);返回 'preferential22';if(localStorage.getItem(str)){ localStorage.removeItem(str) //即可删除昨天的数据}