setCache(){ if(this.judgeTime()){ //判斷緩存是否過期,過期就重新添加一個 wx.setStorageSync('oldTime',this.oldTime()); } } judgeTime(){ //判斷緩存是否過期 let nowTime = Date.now(); let oldTime = wx.getStorageSync('oldTime'); if(oldTime && nowTime < oldTime){ return false; } return true; } oldTime(){ //返回以現在為准的3天后的時間 return Date.now() + 259200000; //毫秒(72小時) } this.setCache();
原文地址:https://blog.csdn.net/frank_hehe/article/details/106471555?utm_medium=distribute.pc_relevant.none-task-blog-OPENSEARCH-2.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-OPENSEARCH-2.control。如有侵權聯系刪除