支持渲染 button 内容

This commit is contained in:
mark.ck 2020-07-17 04:03:10 +08:00
parent 0bcffe9c51
commit f2110d5f73
5 changed files with 24 additions and 9 deletions

View File

@ -962,7 +962,12 @@
"propType": "object", "propType": "object",
"description": "自定义内联样式" "description": "自定义内联样式"
} }
] ],
"configure": {
"component": {
"isContainer": true
}
}
}, },
{ {
"componentName": "Button.Group", "componentName": "Button.Group",
@ -12355,9 +12360,9 @@
"type": "normal", "type": "normal",
"size": "medium", "size": "medium",
"htmlType": "button", "htmlType": "button",
"component": "button", "component": "button"
"children": [ ] },
} "children": "取消"
} }
}, },
{ {
@ -12370,7 +12375,8 @@
"size": "large", "size": "large",
"htmlType": "button", "htmlType": "button",
"component": "button" "component": "button"
} },
"children": "提交"
} }
} }
] ]

View File

@ -112,7 +112,15 @@
}, },
"htmlType": "submit" "htmlType": "submit"
}, },
"children": "提交" "children": [
{
"componentName": "Icon",
"props": {
"type": "success"
}
},
"提交"
]
}, { }, {
"componentName": "Button", "componentName": "Button",
"props": { "props": {

View File

@ -310,7 +310,7 @@ export default class BaseEngine extends PureComponent {
...componentInfo, ...componentInfo,
props: transformArrayToMap(componentInfo.props, 'name'), props: transformArrayToMap(componentInfo.props, 'name'),
}, },
}); }) || {};
// ref // ref
if (acceptsRef(Comp)) { if (acceptsRef(Comp)) {
otherProps.ref = (ref) => { otherProps.ref = (ref) => {

View File

@ -63,6 +63,8 @@ const ENV = {
*/ */
export function isSchema(schema, ignoreArr) { export function isSchema(schema, ignoreArr) {
if (isEmpty(schema)) return false; if (isEmpty(schema)) return false;
// Leaf 组件也返回 true
if (schema.componentName === 'Leaf') return true;
if (!ignoreArr && Array.isArray(schema)) return schema.every((item) => isSchema(item)); if (!ignoreArr && Array.isArray(schema)) return schema.every((item) => isSchema(item));
return !!(schema.componentName && schema.props && (typeof schema.props === 'object' || isJSExpression(schema.props))); return !!(schema.componentName && schema.props && (typeof schema.props === 'object' || isJSExpression(schema.props)));
} }

View File

@ -128,11 +128,10 @@ class Renderer extends Component<{ renderer: SimulatorRenderer }> {
}); });
console.info('menuprops', viewProps); console.info('menuprops', viewProps);
} }
return createElement( return createElement(
getDeviceView(Component, device, designMode), getDeviceView(Component, device, designMode),
viewProps, viewProps,
leaf?.isContainer() ? (children == null ? [] : Array.isArray(children) ? children : [children]) : null, leaf?.isContainer() ? (children == null ? [] : Array.isArray(children) ? children : [children]) : children,
); );
}} }}
onCompGetRef={(schema: any, ref: ReactInstance | null) => { onCompGetRef={(schema: any, ref: ReactInstance | null) => {