至于localStorage如何设置过期时间?
可以对相应的键设置到期时间
expireTime = 60 * 1000; // 过期时间为60s
存储
localStorage.setItem(key, value);
localStorage.setItem(key-expire, ((new Date()).valueOf() + expireTime);
获取
let key-expire = localStorage.getItem(key-expire)
let value = "";
// 当前时间 已经超过 设置的过期时间
if (key-expire < ((new Date()).valueOf()) {
localStorage.removeItem(key);
} else {
value = localStorage.getItem(key);
}