38 lines
1.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { componentRendererFactory, types } from '@alilc/lowcode-renderer-core';
const raxComponentRendererFactory: () => any = () => {
const OriginComponent = componentRendererFactory();
return class ComponentRenderer extends OriginComponent {
render() {
// @ts-ignore
const that: types.IRenderer = this;
const { __schema, __components } = that.props;
if (that.__checkSchema(__schema)) {
return '自定义组件 schema 结构异常!';
}
that.__debug(`render - ${__schema.fileName}`);
const { noContainer } = that.__parseData(__schema.props);
const children = ((context) => {
that.context = context;
that.__generateCtx({ component: that });
that.__render();
// 传 null使用内置的 div 来渲染,解决在页面中渲染 vc-component 报错的问题
return that.__renderComp(null, {
compContext: that,
blockContext: that,
});
});
const content = that.__renderContextConsumer(children);
if (noContainer) {
return content;
}
return that.__renderContent(content);
}
};
};
export default raxComponentRendererFactory;