Browse Source

fix: swiper的销毁钩子内计时器清空无效 #262

richard1015 5 years ago
parent
commit
e35c29583c
1 changed files with 4 additions and 4 deletions
  1. 4 4
      src/packages/swiper/swiper.vue

+ 4 - 4
src/packages/swiper/swiper.vue

@@ -398,8 +398,8 @@ export default {
     this.updateEvent();
   },
   destroyed() {
-    this.timer = null;
-    this.domTimer = null;
+    this.timer && clearInterval(this.timer);
+    this.domTimer && clearTimeout(this.domTimer);
   },
   activated() {
     if (this.keepAlive) {
@@ -409,8 +409,8 @@ export default {
   },
   deactivated() {
     this.keepAlive = true;
-    this.timer = null;
-    this.domTimer = null;
+    this.timer && clearInterval(this.timer);
+    this.domTimer && clearTimeout(this.domTimer);
   }
 };
 </script>