Evan You 10 лет назад
Родитель
Сommit
583a7bb0d1
1 измененных файлов с 8 добавлено и 6 удалено
  1. 8 6
      src/runtime/instance/lifecycle.js

+ 8 - 6
src/runtime/instance/lifecycle.js

@@ -1,14 +1,12 @@
 import Watcher from '../observer/watcher'
-import { defineReactive } from '../observer/index'
-import { set, query, toArray } from '../util/index'
+import { query, toArray } from '../util/index'
 
 export function initLifecycle (vm) {
   vm.$children = []
   vm._isDestroyed = false
   vm._isBeingDestroyed = false
-
-  defineReactive(vm, '$refs', {})
-  defineReactive(vm, '$els', {})
+  vm.$refs = {}
+  vm.$els = {}
 
   const options = vm.$options
 
@@ -23,7 +21,7 @@ export function initLifecycle (vm) {
   vm._context = options._context
   vm._ref = options._renderData && options._renderData.ref
   if (vm._ref) {
-    set(vm._context.$refs, vm._ref, vm)
+    vm._context.$refs[vm._ref] = vm
   }
 }
 
@@ -45,6 +43,10 @@ export function lifecycleMixin (Vue) {
     this._update(this._watcher.value)
     callHook(this, 'mounted')
     this._mounted = true
+    // root instance, call ready on self
+    if (this.$root === this) {
+      callHook(this, 'ready')
+    }
     return this
   }