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

fix(watch): remove recorded effect on manual stop (#590)

Yang Mingshan 6 лет назад
Родитель
Сommit
453e6889da
1 измененных файлов с 7 добавлено и 0 удалено
  1. 7 0
      packages/runtime-core/src/apiWatch.ts

+ 7 - 0
packages/runtime-core/src/apiWatch.ts

@@ -217,6 +217,13 @@ function doWatch(
   recordEffect(runner)
   recordEffect(runner)
   return () => {
   return () => {
     stop(runner)
     stop(runner)
+    if (instance) {
+      const effects = instance.effects!
+      const index = effects.indexOf(runner)
+      if (index > -1) {
+        effects.splice(index, 1)
+      }
+    }
   }
   }
 }
 }