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

separate initRender and initial mounting (fix #4693)

Evan You 9 лет назад
Родитель
Сommit
7131bc4815
2 измененных файлов с 4 добавлено и 4 удалено
  1. 4 1
      src/core/instance/init.js
  2. 0 3
      src/core/instance/render.js

+ 4 - 1
src/core/instance/init.js

@@ -39,10 +39,13 @@ export function initMixin (Vue: Class<Component>) {
     vm._self = vm
     initLifecycle(vm)
     initEvents(vm)
+    initRender(vm)
     callHook(vm, 'beforeCreate')
     initState(vm)
     callHook(vm, 'created')
-    initRender(vm)
+    if (vm.$options.el) {
+      vm.$mount(vm.$options.el)
+    }
   }
 }
 

+ 0 - 3
src/core/instance/render.js

@@ -40,9 +40,6 @@ export function initRender (vm: Component) {
   // normalization is always applied for the public version, used in
   // user-written render functions.
   vm.$createElement = (a, b, c, d) => createElement(vm, a, b, c, d, true)
-  if (vm.$options.el) {
-    vm.$mount(vm.$options.el)
-  }
 }
 
 export function renderMixin (Vue: Class<Component>) {