1 var currentTime = Date.parse(new Date()); //當前時間戳 2 var SetTimeStr = localStorage.getItem('SetTimeStr') * 1; 3 var newTime = new Date().getTime() + 3600000 * 12;//新的過時時間 4 if (currentTime < SetTimeStr) { 5 console.log("緩存時間有效_"); 6 localStorage.setItem('SetTimeStr',newTime) 7 } else { 8 localStorage.setItem('SetTimeStr',newTime) 9 }
免費課程資源分享:https://www.yinxiangit.com/(喜歡IT技術的小夥伴能夠進去看看)git