Ver código fonte

发现页缓存

panhui 4 anos atrás
pai
commit
9ff77c2daf
1 arquivos alterados com 6 adições e 7 exclusões
  1. 6 7
      src/views/Discover.vue

+ 6 - 7
src/views/Discover.vue

@@ -272,18 +272,17 @@ export default {
                 });
                 });
         }
         }
     },
     },
-    watch: {
-        $route() {
-            this.$nextTick(() => {
-                this.changeScroll(this.scrollTop);
-            });
-        }
+    activated() {
+        this.$nextTick(() => {
+            this.changeScroll(this.scrollTop);
+        });
     },
     },
     beforeRouteLeave(to, from, next) {
     beforeRouteLeave(to, from, next) {
-        this.scrollTop = this.scrollWrapper.value.scrollTop;
         if (!to.meta.menuPage) {
         if (!to.meta.menuPage) {
+            this.scrollTop = this.scrollWrapper.value.scrollTop;
             this.setKeeps(['index', 'discover']);
             this.setKeeps(['index', 'discover']);
         } else {
         } else {
+            this.scrollTop = 0;
             this.setKeeps([]);
             this.setKeeps([]);
         }
         }
         next();
         next();