瀏覽代碼

types: allow functional components to return multiple VNodes (#8192)

close #8191
Zev Goldstein 7 年之前
父節點
當前提交
bf2e2ed159
共有 2 個文件被更改,包括 11 次插入1 次删除
  1. 1 1
      types/options.d.ts
  2. 10 0
      types/test/options-test.ts

+ 1 - 1
types/options.d.ts

@@ -113,7 +113,7 @@ export interface FunctionalComponentOptions<Props = DefaultProps, PropDefs = Pro
   props?: PropDefs;
   props?: PropDefs;
   inject?: InjectOptions;
   inject?: InjectOptions;
   functional: boolean;
   functional: boolean;
-  render?(this: undefined, createElement: CreateElement, context: RenderContext<Props>): VNode;
+  render?(this: undefined, createElement: CreateElement, context: RenderContext<Props>): VNode | VNode[];
 }
 }
 
 
 export interface RenderContext<Props=DefaultProps> {
 export interface RenderContext<Props=DefaultProps> {

+ 10 - 0
types/test/options-test.ts

@@ -354,6 +354,16 @@ Vue.component('functional-component-check-optional', {
   functional: true
   functional: true
 })
 })
 
 
+Vue.component('functional-component-multi-root', {
+  functional: true,
+  render(h) {
+    return [
+      h("tr", [h("td", "foo"), h("td", "bar")]),
+      h("tr", [h("td", "lorem"), h("td", "ipsum")])
+    ]
+  }
+})
+
 Vue.component("async-component", ((resolve, reject) => {
 Vue.component("async-component", ((resolve, reject) => {
   setTimeout(() => {
   setTimeout(() => {
     resolve(Vue.component("component"));
     resolve(Vue.component("component"));