Kaynağa Gözat

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

close #8191
Zev Goldstein 7 yıl önce
ebeveyn
işleme
bf2e2ed159
2 değiştirilmiş dosya ile 11 ekleme ve 1 silme
  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;
   inject?: InjectOptions;
   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> {

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

@@ -354,6 +354,16 @@ Vue.component('functional-component-check-optional', {
   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) => {
   setTimeout(() => {
     resolve(Vue.component("component"));