Browse Source

fix:修复InfiniteLoading组件在用keep-alive缓存时首次监听2次问题

richard1015 6 years ago
parent
commit
d77f6187db
1 changed files with 5 additions and 1 deletions
  1. 5 1
      src/packages/infiniteloading/infiniteloading.vue

+ 5 - 1
src/packages/infiniteloading/infiniteloading.vue

@@ -137,10 +137,14 @@ export default {
     },
     },
 
 
     activated() {
     activated() {
-        this.scrollListener();
+        if(this.keepAlive){
+            this.keepAlive = false;
+            this.scrollListener();
+        }
     },
     },
 
 
     deactivated() {
     deactivated() {
+        this.keepAlive = true;
         window.removeEventListener('scroll', this.handleScroll, false);
         window.removeEventListener('scroll', this.handleScroll, false);
         window.removeEventListener('resize', this.handleScroll, false);
         window.removeEventListener('resize', this.handleScroll, false);
     },
     },