fix: 修复最外层非 Page 组件没有渲染且 props 没有完全解析问题

This commit is contained in:
liujuping.liujupin 2021-09-13 10:09:34 +08:00
parent 9066b1b9a4
commit 3bfdf34683
2 changed files with 21 additions and 3 deletions

View File

@ -339,6 +339,14 @@ export default function baseRenererFactory() {
} as IInfo));
};
private get self() {
const { __ctx } = this.props;
const self: any = {};
self.__proto__ = __ctx || this;
return self;
}
// 将模型结构转换成react Element
// schema 模型结构
// self 为每个渲染组件构造的上下文self是自上而下继承的
@ -729,7 +737,11 @@ export default function baseRenererFactory() {
__renderComp(Comp: any, ctxProps: object) {
const { __schema } = this.props;
const data = this.__parseData(__schema?.props);
const data = this.__parseProps(__schema?.props, this.self, '', {
schema: __schema,
Comp,
componentInfo: {},
});
const { className } = data;
const { engine } = this.context || {};
if (!engine) {

View File

@ -19,7 +19,7 @@ export default function componentRendererFactory() {
}
render() {
const { __schema } = this.props;
const { __schema, __components } = this.props;
if (this.__checkSchema(__schema)) {
return '自定义组件 schema 结构异常!';
}
@ -36,7 +36,13 @@ export default function componentRendererFactory() {
return this.__renderContextProvider({ compContext: this });
}
return this.__renderContent(this.__renderContextProvider({ compContext: this }));
const Component = __components[__schema.componentName];
if (!Component) {
return this.__renderContent(this.__renderContextProvider({ compContext: this }));
}
return this.__renderComp(Component, this.__renderContextProvider({ compContext: this }));
}
};
}