mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-02 20:09:08 +08:00
fix: asFormItem 可能会重复包裹 (#2240)
* fix: asFormItem 可能会重复包裹 * chore: component 形式跟 renderer 形式接收的参数保持一致 * chore: component 形式跟 renderer 形式接收的参数保持一致
This commit is contained in:
parent
5517f5b1d0
commit
07f5e64450
@ -134,6 +134,7 @@ export class SchemaRenderer extends React.Component<SchemaRendererProps, any> {
|
||||
|
||||
if (
|
||||
schema.component &&
|
||||
!schema.component.wrapAsFormItem &&
|
||||
(schema.asFormItem ||
|
||||
(props.formStore && (schema.name || schema.hasOwnProperty('label'))))
|
||||
) {
|
||||
@ -147,6 +148,7 @@ export class SchemaRenderer extends React.Component<SchemaRendererProps, any> {
|
||||
...schema.asFormItem
|
||||
})(schema.component);
|
||||
componentCache.set(schema.component, cache);
|
||||
cache.wrapAsFormItem = true;
|
||||
schema.component = cache;
|
||||
}
|
||||
}
|
||||
@ -242,12 +244,21 @@ export class SchemaRenderer extends React.Component<SchemaRendererProps, any> {
|
||||
});
|
||||
} else if (typeof schema.component === 'function') {
|
||||
const isSFC = !(schema.component.prototype instanceof React.Component);
|
||||
const {
|
||||
data: defaultData,
|
||||
value: defaultValue,
|
||||
activeKey: defaultActiveKey,
|
||||
...restSchema
|
||||
} = schema;
|
||||
return rest.invisible
|
||||
? null
|
||||
: React.createElement(schema.component as any, {
|
||||
...rest,
|
||||
...restSchema,
|
||||
...exprProps,
|
||||
...schema,
|
||||
defaultData,
|
||||
defaultValue,
|
||||
defaultActiveKey,
|
||||
$path: $path,
|
||||
$schema: schema,
|
||||
ref: isSFC ? undefined : this.refFn,
|
||||
|
Loading…
Reference in New Issue
Block a user