mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-02 03:58:07 +08:00
parent
b5c7fabbfe
commit
b7036a2930
@ -87,6 +87,7 @@ export default {
|
||||
|
||||
{
|
||||
name: 'a',
|
||||
asFormItem: true,
|
||||
children: ({value, onChange}) => (
|
||||
<div>
|
||||
<p>这是使用 children 的方式,也无需注册。</p>
|
||||
@ -129,6 +130,7 @@ export default {
|
||||
},
|
||||
{
|
||||
label: '',
|
||||
asFormItem: true,
|
||||
children: ({render}) => (
|
||||
<div>
|
||||
<p>组合现有组件</p>
|
||||
@ -158,6 +160,7 @@ export default {
|
||||
{
|
||||
name: 'c',
|
||||
label: '',
|
||||
asFormItem: true,
|
||||
component: ({render, value, onChange, name}) => {
|
||||
function handleXChange(x) {
|
||||
value = {
|
||||
|
@ -121,12 +121,7 @@ export class SchemaRenderer extends React.Component<SchemaRendererProps, any> {
|
||||
} else {
|
||||
// 自定义组件如果在节点设置了 label name 什么的,就用 formItem 包一层
|
||||
// 至少自动支持了 valdiations, label, description 等逻辑。
|
||||
if (
|
||||
schema.children &&
|
||||
!schema.component &&
|
||||
(schema.asFormItem ||
|
||||
(props.formStore && (schema.name || schema.hasOwnProperty('label'))))
|
||||
) {
|
||||
if (schema.children && !schema.component && schema.asFormItem) {
|
||||
schema.component = PlaceholderComponent;
|
||||
schema.renderChildren = schema.children;
|
||||
delete schema.children;
|
||||
@ -134,9 +129,8 @@ export class SchemaRenderer extends React.Component<SchemaRendererProps, any> {
|
||||
|
||||
if (
|
||||
schema.component &&
|
||||
!schema.component.wrapAsFormItem &&
|
||||
(schema.asFormItem ||
|
||||
(props.formStore && (schema.name || schema.hasOwnProperty('label'))))
|
||||
!schema.component.wrapedAsFormItem &&
|
||||
schema.asFormItem
|
||||
) {
|
||||
const cache = componentCache.get(schema.component);
|
||||
|
||||
@ -148,7 +142,7 @@ export class SchemaRenderer extends React.Component<SchemaRendererProps, any> {
|
||||
...schema.asFormItem
|
||||
})(schema.component);
|
||||
componentCache.set(schema.component, cache);
|
||||
cache.wrapAsFormItem = true;
|
||||
cache.wrapedAsFormItem = true;
|
||||
schema.component = cache;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user