Evan You 10 лет назад
Родитель
Сommit
23c1c61053
2 измененных файлов с 14 добавлено и 0 удалено
  1. 12 0
      src/compiler/codegen/index.js
  2. 2 0
      src/runtime/global-api.js

+ 12 - 0
src/compiler/codegen/index.js

@@ -27,6 +27,8 @@ function genElement (el, key) {
     return genIf(el, exp)
   } else if (el.tag === 'template') {
     return genChildren(el)
+  } else if (el.tag === 'render') {
+    return genRender(el)
   } else {
     return `__h__('${el.tag}', ${genData(el, key)}, ${genChildren(el)})`
   }
@@ -163,3 +165,13 @@ function genText (text) {
     }
   }
 }
+
+function genRender (el) {
+  const method = el.attrsMap.method
+  const args = el.attrsMap.args
+  if (process.env.NODE_ENV !== 'production' && !method) {
+    console.error('method attribute is required on <render>.')
+    return 'undefined'
+  }
+  return `${method}(${args})`
+}

+ 2 - 0
src/runtime/global-api.js

@@ -1,5 +1,6 @@
 import config from './config'
 import * as util from './util/index'
+import h from './vdom/h'
 import {
   set,
   del,
@@ -14,6 +15,7 @@ import {
 } from './util/index'
 
 export function initGlobalAPI (Vue) {
+  Vue.h = h
   Vue.config = config
   Vue.util = util
   Vue.set = set