From 18863ede69bb2f9e53af2c4745401e278633004e Mon Sep 17 00:00:00 2001 From: liaoxuezhi <2betop.cn@gmail.com> Date: Fri, 18 Jun 2021 01:13:31 +0800 Subject: [PATCH] Grid --- src/compat.ts | 5 +---- src/renderers/Grid.tsx | 23 ++++++++++++++++++++--- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/compat.ts b/src/compat.ts index ae4b9139d..4836d7c87 100644 --- a/src/compat.ts +++ b/src/compat.ts @@ -511,11 +511,8 @@ addSchemaFilter(function (schema: Schema, renderer: any, props: any) { body: column?.controls.map(controlToNormalRenderer) }; + delete column.type; delete column.controls; - if (!column.type) { - column.type = 'wrapper'; - column.size = 'none'; - } } return column; diff --git a/src/renderers/Grid.tsx b/src/renderers/Grid.tsx index 22681fb73..3daa25d9b 100644 --- a/src/renderers/Grid.tsx +++ b/src/renderers/Grid.tsx @@ -2,7 +2,12 @@ import React from 'react'; import {Renderer, RendererProps} from '../factory'; import {Schema} from '../types'; import pick from 'lodash/pick'; -import {BaseSchema, SchemaClassName, SchemaObject} from '../Schema'; +import { + BaseSchema, + SchemaClassName, + SchemaCollection, + SchemaObject +} from '../Schema'; export const ColProps = ['lg', 'md', 'sm', 'xs']; @@ -106,6 +111,8 @@ export type GridColumnObject = { mode?: string; horizontal?: any; + body?: SchemaCollection; + /** * 列类名 */ @@ -168,7 +175,12 @@ export default class Grid extends React.Component { static propsList: Array = ['columns']; static defaultProps = {}; - renderChild(region: string, node: Schema, key: number, length: number) { + renderChild( + region: string, + node: SchemaCollection, + key: number, + length: number + ) { const {render, itemRender} = this.props; return itemRender @@ -206,7 +218,12 @@ export default class Grid extends React.Component { )} ) : ( - this.renderChild(`column/${key}`, column, key, length) + this.renderChild( + `column/${key}`, + column.type ? column : (column as any).body!, + key, + length + ) )} );