Selaa lähdekoodia

tweak wathcer

Evan You 9 vuotta sitten
vanhempi
commit
065b8b3d5f
1 muutettua tiedostoa jossa 9 lisäystä ja 5 poistoa
  1. 9 5
      src/core/observer/watcher.js

+ 9 - 5
src/core/observer/watcher.js

@@ -40,15 +40,19 @@ export default class Watcher {
     vm: Component,
     vm: Component,
     expOrFn: string | Function,
     expOrFn: string | Function,
     cb: Function,
     cb: Function,
-    options?: Object = {}
+    options?: Object
   ) {
   ) {
     this.vm = vm
     this.vm = vm
     vm._watchers.push(this)
     vm._watchers.push(this)
     // options
     // options
-    this.deep = !!options.deep
-    this.user = !!options.user
-    this.lazy = !!options.lazy
-    this.sync = !!options.sync
+    if (options) {
+      this.deep = !!options.deep
+      this.user = !!options.user
+      this.lazy = !!options.lazy
+      this.sync = !!options.sync
+    } else {
+      this.deep = this.user = this.lazy = this.sync = false
+    }
     this.cb = cb
     this.cb = cb
     this.id = ++uid // uid for batching
     this.id = ++uid // uid for batching
     this.active = true
     this.active = true