Просмотр исходного кода

增加清理时间缓存的方法

tanxue 19 часов назад
Родитель
Сommit
0c4fececdd
1 измененных файлов с 10 добавлено и 2 удалено
  1. 10 2
      pages/chanpinZiliao/index.vue

+ 10 - 2
pages/chanpinZiliao/index.vue

@@ -38,7 +38,7 @@ import YingYuList  from "./yingyu/yyList.vue"
 import YuWenList  from "./yuwen/ywList.vue"
 import {useSelectDateForUpdate} from "@/utils/common";
 let currentTabIndex = ref(2);
-const {isNowDate} = useSelectDateForUpdate('ziliaoDate')
+const {isNowDate,resetDate} = useSelectDateForUpdate('ziliaoDate')
 const data = reactive({
 	list:[
 	  { key: 'shuxue', label: '数学' },
@@ -62,7 +62,15 @@ function getZiliaoList() {
     const result = getFormatData(res.data);
     data.shuxueList = result.shuxue;
     data.yingyuList = result.yingyu;
-    data.yuwenList = result.yuwen;
+    data.yingyuList = result.yuwen;
+	
+	if (!data.shuxueList.length && !data.yingyuList.length && !data.yingyuList.length) {
+		// 并无数据时,清理时间缓存
+		resetDate()
+	}
+  }).catch(err => {
+			// 请求异常时,清理时间缓存
+		resetDate()
   })
 }